U:RDoc::AnyMethod[iI"[]=:ETI"Array#[]=;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"PElement Assignment --- Sets the element at +index+, or replaces a subarray ;TI"Jfrom the +start+ index for +length+ elements, or replaces a subarray ;TI")specified by the +range+ of indices.;To:RDoc::Markup::BlankLineo; ; [I"NIf indices are greater than the current capacity of the array, the array ;TI"Ngrows automatically. Elements are inserted into the array at +start+ if ;TI"+length+ is zero.;T@o; ; [I"JNegative indices will count backward from the end of the array. For ;TI"L+start+ and +range+ cases the starting index is just before an element.;T@o; ; [I"NAn IndexError is raised if a negative index points past the beginning of ;TI"the array.;T@o; ; [I",See also Array#push, and Array#unshift.;T@o:RDoc::Markup::Verbatim; [I"a = Array.new ;TI"?a[4] = "4"; #=> [nil, nil, nil, nil, "4"] ;TI"?a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"] ;TI";a[1..2] = [ 1, 2 ] #=> ["a", 1, 2, nil, "4"] ;TI"8a[0, 2] = "?" #=> ["?", 2, nil, "4"] ;TI"0a[0..2] = "A" #=> ["A", "4"] ;TI"0a[-1] = "Z" #=> ["A", "Z"] ;TI"0a[1..-1] = nil #=> ["A", nil] ;TI"+a[1..-1] = [] #=> ["A"] ;TI"1a[0, 0] = [ 1, 2 ] #=> [1, 2, "A"] ;TI"5a[3, 0] = "B" #=> [1, 2, "A", "B"];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Êary[index] = obj -> obj ary[start, length] = obj or other_ary or nil -> obj or other_ary or nil ary[range] = obj or other_ary or nil -> obj or other_ary or nil ;T0[I" (*args);T@.FI" Array;TcRDoc::NormalClass00