ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- PK]CYY length-i.rinu[U:RDoc::AnyMethod[iI" length:ETI"Array#length;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"-Returns the count of elements in +self+.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I" array.length -> an_integer ;T0[[I" size;T@ I"();T@FI" Array;TcRDoc::NormalClass00PK]T,||zip-i.rinu[U:RDoc::AnyMethod[iI"zip:ETI"Array#zip;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"VWhen no block given, returns a new \Array +new_array+ of size self.size ;TI"whose elements are Arrays.;To:RDoc::Markup::BlankLineo; ; [I"VEach nested array new_array[n] is of size other_arrays.size+1, ;TI"and contains:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"!The _nth_ element of +self+.;To;;0; [o; ; [I"5The _nth_ element of each of the +other_arrays+.;T@o; ; [I"8If all +other_arrays+ and +self+ are the same size:;To:RDoc::Markup::Verbatim; [ I"a = [:a0, :a1, :a2, :a3] ;TI"b = [:b0, :b1, :b2, :b3] ;TI"c = [:c0, :c1, :c2, :c3] ;TI"d = a.zip(b, c) ;TI"Qd # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] ;T: @format0o; ; [I"self.size with +nil+:;To;; [ I"a = [:a0, :a1, :a2, :a3] ;TI"b = [:b0, :b1, :b2] ;TI"c = [:c0, :c1] ;TI"d = a.zip(b, c) ;TI"Qd # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] ;T;0o; ; [I";If any array in +other_arrays+ is larger than +self+, ;TI"'its trailing elements are ignored:;To;; [ I"a = [:a0, :a1, :a2, :a3] ;TI"#b = [:b0, :b1, :b2, :b3, :b4] ;TI"(c = [:c0, :c1, :c2, :c3, :c4, :c5] ;TI"d = a.zip(b, c) ;TI"Qd # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] ;T;0o; ; [I"fWhen a block is given, calls the block with each of the sub-arrays (formed as above); returns nil;To;; [ I"a = [:a0, :a1, :a2, :a3] ;TI"b = [:b0, :b1, :b2, :b3] ;TI"c = [:c0, :c1, :c2, :c3] ;TI"4a.zip(b, c) {|sub_array| p sub_array} # => nil ;T;0o; ; [I" Output:;To;; [ I"[:a0, :b0, :c0] ;TI"[:a1, :b1, :c1] ;TI"[:a2, :b2, :c2] ;TI"[:a3, :b3, :c3];T;0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"`array.zip(*other_arrays) -> new_array array.zip(*other_arrays) {|other_array| ... } -> nil ;T0[I" (*args);T@RFI" Array;TcRDoc::NormalClass00PK] fill-i.rinu[U:RDoc::AnyMethod[iI" fill:ETI"Array#fill;TF: privateo:RDoc::Markup::Document: @parts[Go:RDoc::Markup::Paragraph; [I"RReplaces specified elements in +self+ with specified objects; returns +self+.;To:RDoc::Markup::BlankLineo; ; [I"XWith argument +obj+ and no block given, replaces all elements with that one object:;To:RDoc::Markup::Verbatim; [I"a = ['a', 'b', 'c', 'd'] ;TI"!a # => ["a", "b", "c", "d"] ;TI"&a.fill(:X) # => [:X, :X, :X, :X] ;T: @format0o; ; [I"DWith arguments +obj+ and \Integer +start+, and no block given, ;TI"0replaces elements based on the given start.;T@o; ; [I"@If +start+ is in range (0 <= start < array.size), ;TI"?replaces all elements from offset +start+ through the end:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"+a.fill(:X, 2) # => ["a", "b", :X, :X] ;T; 0o; ; [I"JIf +start+ is too large (start >= array.size), does nothing:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"-a.fill(:X, 4) # => ["a", "b", "c", "d"] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"-a.fill(:X, 5) # => ["a", "b", "c", "d"] ;T; 0o; ; [I"aIf +start+ is negative, counts from the end (starting index is start + array.size):;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI",a.fill(:X, -2) # => ["a", "b", :X, :X] ;T; 0o; ; [I"RIf +start+ is too small (less than and far from zero), replaces all elements:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"*a.fill(:X, -6) # => [:X, :X, :X, :X] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"+a.fill(:X, -50) # => [:X, :X, :X, :X] ;T; 0o; ; [I"XWith arguments +obj+, \Integer +start+, and \Integer +length+, and no block given, ;TI"?replaces elements based on the given +start+ and +length+.;T@o; ; [I"TIf +start+ is in range, replaces +length+ elements beginning at offset +start+:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"/a.fill(:X, 1, 1) # => ["a", :X, "c", "d"] ;T; 0o; ; [I"1If +start+ is negative, counts from the end:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"0a.fill(:X, -2, 1) # => ["a", "b", :X, "d"] ;T; 0o; ; [I"SIf +start+ is large (start >= array.size), extends +self+ with +nil+:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"5a.fill(:X, 5, 0) # => ["a", "b", "c", "d", nil] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"=a.fill(:X, 5, 2) # => ["a", "b", "c", "d", nil, :X, :X] ;T; 0o; ; [I";If +length+ is zero or negative, replaces no elements:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"0a.fill(:X, 1, 0) # => ["a", "b", "c", "d"] ;TI"1a.fill(:X, 1, -1) # => ["a", "b", "c", "d"] ;T; 0o; ; [I"BWith arguments +obj+ and \Range +range+, and no block given, ;TI"0replaces elements based on the given range.;T@o; ; [I"UIf the range is positive and ascending (0 < range.begin <= range.end), ;TI"Greplaces elements from range.begin to range.end:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"1a.fill(:X, (1..1)) # => ["a", :X, "c", "d"] ;T; 0o; ; [I"?If range.first is negative, replaces no elements:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"3a.fill(:X, (-1..1)) # => ["a", "b", "c", "d"] ;T; 0o; ; [I"=If range.last is negative, counts from the end:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"0a.fill(:X, (0..-2)) # => [:X, :X, :X, "d"] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"1a.fill(:X, (1..-2)) # => ["a", :X, :X, "d"] ;T; 0o; ; [I"GIf range.last and range.last are both negative, ;TI"*both count from the end of the array:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"3a.fill(:X, (-1..-1)) # => ["a", "b", "c", :X] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"3a.fill(:X, (-2..-2)) # => ["a", "b", :X, "d"] ;T; 0o; ; [I"KWith no arguments and a block given, calls the block with each index; ;TI"Freplaces the corresponding element with the block's return value:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"Qa.fill { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] ;T; 0o; ; [I"NWith argument +start+ and a block given, calls the block with each index ;TI"Hfrom offset +start+ to the end; replaces the corresponding element ;TI"#with the block's return value:;T@o; ; [I">If start is in range (0 <= start < array.size), ;TI"-replaces from offset +start+ to the end:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"Pa.fill(1) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "new_3"] ;T; 0o; ; [I"IIf +start+ is too large(start >= array.size), does nothing:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"Ja.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"Ja.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] ;T; 0o; ; [I"1If +start+ is negative, counts from the end:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"Ma.fill(-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "new_3"] ;T; 0o; ; [I"QIf start is too small (start <= -array.size, replaces all elements:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"Ua.fill(-6) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"Va.fill(-50) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] ;T; 0o; ; [I"=With arguments +start+ and +length+, and a block given, ;TI"?calls the block for each index specified by start length; ;TI"Freplaces the corresponding element with the block's return value.;T@o; ; [I"TIf +start+ is in range, replaces +length+ elements beginning at offset +start+:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"Ka.fill(1, 1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"] ;T; 0o; ; [I"/If start is negative, counts from the end:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"La.fill(-2, 1) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"] ;T; 0o; ; [I"SIf +start+ is large (start >= array.size), extends +self+ with +nil+:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"La.fill(5, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"^a.fill(5, 2) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil, "new_5", "new_6"] ;T; 0o; ; [I"7If +length+ is zero or less, replaces no elements:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"Ga.fill(1, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d"] ;TI"Ha.fill(1, -1) { |index| "new_#{index}" } # => ["a", "b", "c", "d"] ;T; 0o; ; [I":With arguments +obj+ and +range+, and a block given, ;TI"9calls the block with each index in the given range; ;TI"Freplaces the corresponding element with the block's return value.;T@o; ; [I"ZIf the range is positive and ascending (range 0 < range.begin <= range.end, ;TI"Greplaces elements from range.begin to range.end:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"Ka.fill(1..1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"] ;T; 0o; ; [I"0If +range.first+ is negative, does nothing:;To; ; [I"a = ['a', 'b', 'c', 'd'] ;TI"Na.fill(-1..1) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] ;T; 0o; ; [I"=If range.last is negative, counts from the end:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"Ta.fill(0..-2) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "d"] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"Pa.fill(1..-2) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "d"] ;T; 0o; ; [I"HIf range.first and range.last are both negative, ;TI"both count from the end:;To; ; [ I"a = ['a', 'b', 'c', 'd'] ;TI"Ma.fill(-1..-1) { |index| "new_#{index}" } # => ["a", "b", "c", "new_3"] ;TI"a = ['a', 'b', 'c', 'd'] ;TI"La.fill(-2..-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I""array.fill(obj) -> self array.fill(obj, start) -> self array.fill(obj, start, length) -> self array.fill(obj, range) -> self array.fill {|index| ... } -> self array.fill(start) {|index| ... } -> self array.fill(start, length) {|index| ... } -> self array.fill(range) {|index| ... } -> self ;T0[I"(p1 = v1, p2 = v2);T@FI" Array;TcRDoc::NormalClass00PK]) map%21-i.rinu[U:RDoc::AnyMethod[iI" map!:ETI"Array#map!;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"3Calls the block, if given, with each element; ;TI"8replaces the element with the block's return value:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"Ga.map! { |element| element.class } # => [Symbol, String, Integer] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.map! ;TI"2a1 # => # ;T; 0o; ; [I"/Array#collect! is an alias for Array#map!.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Array;TcRDoc::NormalClass0[@!FI" collect!;TPK]aZZdifference-i.rinu[U:RDoc::AnyMethod[iI"difference:ETI"Array#difference;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"EReturns a new \Array containing only those elements from +self+ ;TI"=that are not found in any of the Arrays +other_arrays+; ;TI"Mitems are compared using eql?; order from +self+ is preserved:;To:RDoc::Markup::Verbatim; [I"@[0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3] ;TI"6[0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2] ;TI".[0, 1, 2].difference([4]) # => [0, 1, 2] ;T: @format0o; ; [I"4Returns a copy of +self+ if no arguments given.;To:RDoc::Markup::BlankLineo; ; [I"Related: Array#-.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"2array.difference(*other_arrays) -> new_array ;T0[I" (*args);T@FI" Array;TcRDoc::NormalClass00PK]?Zhhvalues_at-i.rinu[U:RDoc::AnyMethod[iI"values_at:ETI"Array#values_at;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I":Returns a new \Array whose elements are the elements ;TI"9of +self+ at the given \Integer or \Range +indexes+.;To:RDoc::Markup::BlankLineo; ; [I"FFor each positive +index+, returns the element at offset +index+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"&a.values_at(0, 2) # => [:foo, 2] ;TI"*a.values_at(0..1) # => [:foo, "bar"] ;T: @format0o; ; [I"=The given +indexes+ may be in any order, and may repeat:;To; ; [I"a = [:foo, 'bar', 2] ;TI"?a.values_at(2, 0, 1, 0, 2) # => [2, :foo, "bar", :foo, 2] ;TI"7a.values_at(1, 0..2) # => ["bar", :foo, "bar", 2] ;T; 0o; ; [I"4Assigns +nil+ for an +index+ that is too large:;To; ; [I"a = [:foo, 'bar', 2] ;TI":a.values_at(0, 3, 1, 3) # => [:foo, nil, "bar", nil] ;T; 0o; ; [I"6Returns a new empty \Array if no arguments given.;T@o; ; [I"JFor each negative +index+, counts backward from the end of the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"(a.values_at(-1, -3) # => [2, :foo] ;T; 0o; ; [I"4Assigns +nil+ for an +index+ that is too small:;To; ; [I"a = [:foo, 'bar', 2] ;TI"Ba.values_at(0, -5, 1, -6, 2) # => [:foo, nil, "bar", nil, 2] ;T; 0o; ; [I"5The given +indexes+ may have a mixture of signs:;To; ; [I"a = [:foo, 'bar', 2] ;TI";a.values_at(0, -2, 1, -1) # => [:foo, "bar", "bar", 2];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I",array.values_at(*indexes) -> new_array ;T0[I" (*args);T@?FI" Array;TcRDoc::NormalClass00PK]l uniq%21-i.rinu[U:RDoc::AnyMethod[iI" uniq!:ETI"Array#uniq!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"YRemoves duplicate elements from +self+, the first occurrence always being retained; ;TI"=returns +self+ if any elements removed, +nil+ otherwise.;To:RDoc::Markup::BlankLineo; ; [I"UWith no block given, identifies and removes elements using method eql? ;TI"to compare.;T@o; ; [I",Returns +self+ if any elements removed:;To:RDoc::Markup::Verbatim; [I"a = [0, 0, 1, 1, 2, 2] ;TI"a.uniq! # => [0, 1, 2] ;T: @format0o; ; [I"*Returns +nil+ if no elements removed.;T@o; ; [I";With a block given, calls the block for each element; ;TI"9identifies (using method eql?) and removes ;TI";elements for which the block returns duplicate values.;T@o; ; [I",Returns +self+ if any elements removed:;To; ; [I".a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] ;TI"?a.uniq! {|element| element.size } # => ['a', 'aa', 'aaa'] ;T; 0o; ; [I"*Returns +nil+ if no elements removed.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Larray.uniq! -> self or nil array.uniq! {|element| ... } -> self or nil ;T0[I"();T@-FI" Array;TcRDoc::NormalClass00PK]x/;;take_while-i.rinu[U:RDoc::AnyMethod[iI"take_while:ETI"Array#take_while;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"NReturns a new \Array containing zero or more leading elements of +self+; ;TI"does not modify +self+.;To:RDoc::Markup::BlankLineo; ; [I"QWith a block given, calls the block with each successive element of +self+; ;TI"2stops if the block returns +false+ or +nil+; ;TI"_returns a new Array containing those elements for which the block returned a truthy value:;To:RDoc::Markup::Verbatim; [ I"a = [0, 1, 2, 3, 4, 5] ;TI":a.take_while {|element| element < 3 } # => [0, 1, 2] ;TI" [0, 1, 2, 3, 4, 5] ;TI"a # => [0, 1, 2, 3, 4, 5] ;T: @format0o; ; [I"4With no block given, returns a new \Enumerator:;To; ; [I"<[0, 1].take_while # => #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Warray.take_while {|element| ... } -> new_array array.take_while -> new_enumerator ;T0[I"();T@!FI" Array;TcRDoc::NormalClass00PK]|try_convert-c.rinu[U:RDoc::AnyMethod[iI"try_convert:ETI"Array::try_convert;TT: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"7If +object+ is an \Array object, returns +object+.;To:RDoc::Markup::BlankLineo; ; [I"9Otherwise if +object+ responds to :to_ary, ;TI"9calls object.to_ary and returns the result.;T@o; ; [I"CReturns +nil+ if +object+ does not respond to :to_ary;T@o; ; [I"PRaises an exception unless object.to_ary returns an \Array object.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I" object, new_array, or nil ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]I $$dig-i.rinu[U:RDoc::AnyMethod[iI"dig:ETI"Array#dig;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I"4Finds and returns the object in nested objects ;TI"5that is specified by +index+ and +identifiers+. ;TI"=The nested objects may be instances of various classes. ;TI"2See {Dig Methods}[rdoc-ref:dig_methods.rdoc].;To:RDoc::Markup::BlankLineo; ; [I"Examples:;To:RDoc::Markup::Verbatim; [ I",a = [:foo, [:bar, :baz, [:bat, :bam]]] ;TI".a.dig(1) # => [:bar, :baz, [:bat, :bam]] ;TI"#a.dig(1, 2) # => [:bat, :bam] ;TI"a.dig(1, 2, 0) # => :bat ;TI"a.dig(1, 2, 3) # => nil;T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I".array.dig(index, *identifiers) -> object ;T0[I" (*args);T@FI" Array;TcRDoc::NormalClass00PK]v2YYsort_by%21-i.rinu[U:RDoc::AnyMethod[iI" sort_by!:ETI"Array#sort_by!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I",Sorts the elements of +self+ in place, ;TI"=using an ordering determined by the block; returns self.;To:RDoc::Markup::BlankLineo; ; [I"3Calls the block with each successive element; ;TI"@sorts elements based on the values returned from the block.;T@o; ; [I"^For duplicates returned by the block, the ordering is indeterminate, and may be unstable.;T@o; ; [I"5This example sorts strings based on their sizes:;To:RDoc::Markup::Verbatim; [I"$a = ['aaaa', 'bbb', 'cc', 'd'] ;TI"*a.sort_by! {|element| element.size } ;TI"'a # => ["d", "cc", "bbb", "aaaa"] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;T@o; ; [I"$a = ['aaaa', 'bbb', 'cc', 'd'] ;TI"Ga.sort_by! # => #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Narray.sort_by! {|element| ... } -> self array.sort_by! -> new_enumerator ;T0[I"();T@&FI" Array;TcRDoc::NormalClass00PK] in range if it is smaller than ;TI"3the size of the array. For a 3-element array:;To;;;;[o;;0;[o; ;[I"&Indexes 0 through 2 are in range.;To;;0;[o; ;[I"Index 3 is out of range.;T@o; ;[I"BA negative index is in range if its absolute value is ;TI"Cnot larger than the size of the array. For a 3-element array:;To;;;;[o;;0;[o; ;[I"(Indexes -1 through -3 are in range.;To;;0;[o; ;[I"Index -4 is out of range.;T@S; ; i; I"Creating Arrays;T@o; ;[I"5You can create an \Array object explicitly with:;T@o;;;;[o;;0;[o; ;[I"LAn {array literal}[doc/syntax/literals_rdoc.html#label-Array+Literals].;T@o; ;[I"4You can convert certain objects to Arrays with:;T@o;;;;[o;;0;[o; ;[I"1\Method {Array}[Kernel.html#method-i-Array].;T@o; ;[I" [1, "two", 3.0] ;T: @format0o; ;[I"FAn array can also be created by calling Array.new with zero, one ;TI"N(the initial size of the Array) or two arguments (the initial size and a ;TI"default object).;T@o;;[I"ary = Array.new #=> [] ;TI",Array.new(3) #=> [nil, nil, nil] ;TI"/Array.new(3, true) #=> [true, true, true] ;T;0o; ;[ I"NNote that the second argument populates the array with references to the ;TI"Osame object. Therefore, it is only recommended in cases when you need to ;TI"Iinstantiate arrays with natively immutable objects such as Symbols, ;TI"numbers, true or false.;T@o; ;[I"MTo create an array with separate objects a block can be passed instead. ;TI"PThis method is safe to use with mutable objects such as hashes, strings or ;TI"other arrays:;T@o;;[I"5Array.new(4) {Hash.new} #=> [{}, {}, {}, {}] ;TI"9Array.new(4) {|i| i.to_s } #=> ["0", "1", "2", "3"] ;T;0o; ;[I"CThis is also a quick way to build up multi-dimensional arrays:;T@o;;[I"/empty_table = Array.new(3) {Array.new(3)} ;TI"=#=> [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]] ;T;0o; ;[I"KAn array can also be created by using the Array() method, provided by ;TI"EKernel, which tries to call #to_ary, then #to_a on its argument.;T@o;;[I">Array({:a => "a", :b => "b"}) #=> [[:a, "a"], [:b, "b"]] ;T;0S; ; i; I"Example Usage;T@o; ;[I"OIn addition to the methods it mixes in through the Enumerable module, the ;TI"PArray class has proprietary methods for accessing, searching and otherwise ;TI"manipulating arrays.;T@o; ;[I"8Some of the more common ones are illustrated below.;T@S; ; i; I"Accessing Elements;T@o; ;[ I"NElements in an array can be retrieved using the Array#[] method. It can ;TI"Ktake a single integer argument (a numeric index), a pair of arguments ;TI"R(start and length) or a range. Negative indices start counting from the end, ;TI"$with -1 being the last element.;T@o;;[ I"arr = [1, 2, 3, 4, 5, 6] ;TI"arr[2] #=> 3 ;TI"arr[100] #=> nil ;TI"arr[-3] #=> 4 ;TI"arr[2, 3] #=> [3, 4, 5] ;TI" arr[1..4] #=> [2, 3, 4, 5] ;TI"arr[1..-3] #=> [2, 3, 4] ;T;0o; ;[I"PAnother way to access a particular array element is by using the #at method;T@o;;[I"arr.at(0) #=> 1 ;T;0o; ;[I"@The #slice method works in an identical manner to Array#[].;T@o; ;[I"JTo raise an error for indices outside of the array bounds or else to ;TI"Cprovide a default value when that happens, you can use #fetch.;T@o;;[I"*arr = ['a', 'b', 'c', 'd', 'e', 'f'] ;TI"Narr.fetch(100) #=> IndexError: index 100 outside of array bounds: -6...6 ;TI"'arr.fetch(100, "oops") #=> "oops" ;T;0o; ;[I"IThe special methods #first and #last will return the first and last ;TI"(elements of an array, respectively.;T@o;;[I"arr.first #=> 1 ;TI"arr.last #=> 6 ;T;0o; ;[I" [1, 2, 3] ;T;0o; ;[I"K#drop does the opposite of #take, by returning the elements after +n+ ;TI" elements have been dropped:;T@o;;[I"arr.drop(3) #=> [4, 5, 6] ;T;0S; ; i; I")Obtaining Information about an Array;T@o; ;[I"LArrays keep track of their own length at all times. To query an array ;TI"Labout the number of elements it contains, use #length, #count or #size.;T@o;;[I"?browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE'] ;TI"browsers.length #=> 5 ;TI"browsers.count #=> 5 ;T;0o; ;[I";To check whether an array contains any elements at all;T@o;;[I"browsers.empty? #=> false ;T;0o; ;[I"@To check whether a particular item is included in the array;T@o;;[I".browsers.include?('Konqueror') #=> false ;T;0S; ; i; I"Adding Items to Arrays;T@o; ;[I"KItems can be added to the end of an array by using either #push or #<<;T@o;;[I"arr = [1, 2, 3, 4] ;TI"%arr.push(5) #=> [1, 2, 3, 4, 5] ;TI"(arr << 6 #=> [1, 2, 3, 4, 5, 6] ;T;0o; ;[I"?#unshift will add a new item to the beginning of an array.;T@o;;[I".arr.unshift(0) #=> [0, 1, 2, 3, 4, 5, 6] ;T;0o; ;[I"HWith #insert you can add a new element to an array at any position.;T@o;;[I"@arr.insert(3, 'apple') #=> [0, 1, 2, 'apple', 3, 4, 5, 6] ;T;0o; ;[I"KUsing the #insert method, you can also insert multiple values at once:;T@o;;[I"3arr.insert(3, 'orange', 'pear', 'grapefruit') ;TI"H#=> [0, 1, 2, "orange", "pear", "grapefruit", "apple", 3, 4, 5, 6] ;T;0S; ; i; I"!Removing Items from an Array;T@o; ;[I"IThe method #pop removes the last element in an array and returns it:;T@o;;[I"arr = [1, 2, 3, 4, 5, 6] ;TI"arr.pop #=> 6 ;TI"arr #=> [1, 2, 3, 4, 5] ;T;0o; ;[I"HTo retrieve and at the same time remove the first item, use #shift:;T@o;;[I"arr.shift #=> 1 ;TI"arr #=> [2, 3, 4, 5] ;T;0o; ;[I"0To delete an element at a particular index:;T@o;;[I"arr.delete_at(2) #=> 4 ;TI"arr #=> [2, 3, 5] ;T;0o; ;[I"FTo delete a particular element anywhere in an array, use #delete:;T@o;;[I"arr = [1, 2, 2, 3] ;TI"arr.delete(2) #=> 2 ;TI"arr #=> [1,3] ;T;0o; ;[I"IA useful method if you need to remove +nil+ values from an array is ;TI"#compact:;T@o;;[ I"1arr = ['foo', 0, nil, 'bar', 7, 'baz', nil] ;TI"2arr.compact #=> ['foo', 0, 'bar', 7, 'baz'] ;TI" ['foo', 0, nil, 'bar', 7, 'baz', nil] ;TI"2arr.compact! #=> ['foo', 0, 'bar', 7, 'baz'] ;TI"2arr #=> ['foo', 0, 'bar', 7, 'baz'] ;T;0o; ;[I"GAnother common need is to remove duplicate elements from an array.;T@o; ;[I"DIt has the non-destructive #uniq, and destructive method #uniq!;T@o;;[I"3arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556] ;TI"/arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123] ;T;0S; ; i; I"Iterating over Arrays;T@o; ;[ I"LLike all classes that include the Enumerable module, Array has an each ;TI"Nmethod, which defines what elements should be iterated over and how. In ;TI"Ncase of Array's #each, all elements in the Array instance are yielded to ;TI"$the supplied block in sequence.;T@o; ;[I"9Note that this operation leaves the array unchanged.;T@o;;[ I"arr = [1, 2, 3, 4, 5] ;TI"'arr.each {|a| print a -= 10, " "} ;TI"# prints: -9 -8 -7 -6 -5 ;TI"#=> [1, 2, 3, 4, 5] ;T;0o; ;[I"PAnother sometimes useful iterator is #reverse_each which will iterate over ;TI"0the elements in the array in reverse order.;T@o;;[ I"7words = %w[first second third fourth fifth sixth] ;TI"str = "" ;TI"3words.reverse_each {|word| str += "#{word} "} ;TI"8p str #=> "sixth fifth fourth third second first " ;T;0o; ;[I"MThe #map method can be used to create a new array based on the original ;TI"?array, but with the values modified by the supplied block:;T@o;;[ I"0arr.map {|a| 2*a} #=> [2, 4, 6, 8, 10] ;TI"/arr #=> [1, 2, 3, 4, 5] ;TI"1arr.map! {|a| a**2} #=> [1, 4, 9, 16, 25] ;TI"1arr #=> [1, 4, 9, 16, 25] ;T;0S; ; i; I""Selecting Items from an Array;T@o; ;[ I"OElements can be selected from an array according to criteria defined in a ;TI"Lblock. The selection can happen in a destructive or a non-destructive ;TI"Omanner. While the destructive operations will modify the array they were ;TI"Pcalled on, the non-destructive methods usually return a new array with the ;TI"?selected elements, but leave the original array unchanged.;T@S; ; i; I"Non-destructive Selection;T@o;;[ I"arr = [1, 2, 3, 4, 5, 6] ;TI"0arr.select {|a| a > 3} #=> [4, 5, 6] ;TI"3arr.reject {|a| a < 3} #=> [3, 4, 5, 6] ;TI"0arr.drop_while {|a| a < 4} #=> [4, 5, 6] ;TI"9arr #=> [1, 2, 3, 4, 5, 6] ;T;0S; ; i; I"Destructive Selection;T@o; ;[I"P#select! and #reject! are the corresponding destructive methods to #select ;TI"and #reject;T@o; ;[I"LSimilar to #select vs. #reject, #delete_if and #keep_if have the exact ;TI"7opposite result when supplied with the same block:;T@o;;[ I"/arr.delete_if {|a| a < 4} #=> [4, 5, 6] ;TI"/arr #=> [4, 5, 6] ;TI" ;TI"arr = [1, 2, 3, 4, 5, 6] ;TI"-arr.keep_if {|a| a < 4} #=> [1, 2, 3] ;TI"-arr #=> [1, 2, 3] ;T;0S; ; i; I"What's Here;T@o; ;[I",First, what's elsewhere. \Class \Array:;T@o;;;;[o;;0;[o; ;[I"PInherits from {class Object}[Object.html#class-Object-label-What-27s+Here].;To;;0;[o; ;[I"ZIncludes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], ;TI"1which provides dozens of additional methods.;T@o; ;[I"=Here, class \Array provides methods that are useful for:;T@o;;;;[o;;0;[o; ;[I"J{Creating an Array}[#class-Array-label-Methods+for+Creating+an+Array];To;;0;[o; ;[I"8{Querying}[#class-Array-label-Methods+for+Querying];To;;0;[o; ;[I":{Comparing}[#class-Array-label-Methods+for+Comparing];To;;0;[o; ;[I"8{Fetching}[#class-Array-label-Methods+for+Fetching];To;;0;[o; ;[I":{Assigning}[#class-Array-label-Methods+for+Assigning];To;;0;[o; ;[I"8{Deleting}[#class-Array-label-Methods+for+Deleting];To;;0;[o; ;[I":{Combining}[#class-Array-label-Methods+for+Combining];To;;0;[o; ;[I":{Iterating}[#class-Array-label-Methods+for+Iterating];To;;0;[o; ;[I"<{Converting}[#class-Array-label-Methods+for+Converting];To;;0;[o; ;[I"5{And more....}[#class-Array-label-Other+Methods];T@S; ; i; I""Methods for Creating an Array;T@o;;: NOTE;[o;;[I" ::[];T;[o; ;[I"6Returns a new array populated with given objects.;To;;[I" ::new;T;[o; ;[I"Returns a new array.;To;;[I"::try_convert;T;[o; ;[I"5Returns a new array created from a given object.;T@S; ; i; I"Methods for Querying;T@o;;;;[o;;[I"#length, #size;T;[o; ;[I"#Returns the count of elements.;To;;[I"#include?;T;[o; ;[I"== a given object.;To;;[I" #empty?;T;[o; ;[I"+Returns whether there are no elements.;To;;[I" #all?;T;[o; ;[I"9Returns whether all elements meet a given criterion.;To;;[I" #any?;T;[o; ;[I"9Returns whether any element meets a given criterion.;To;;[I" #none?;T;[o; ;[I";Returns whether no element == a given object.;To;;[I" #one?;T;[o; ;[I"DReturns whether exactly one element == a given object.;To;;[I" #count;T;[o; ;[I"?Returns the count of elements that meet a given criterion.;To;;[I"#find_index, #index;T;[o; ;[I"IReturns the index of the first element that meets a given criterion.;To;;[I" #rindex;T;[o; ;[I"HReturns the index of the last element that meets a given criterion.;To;;[I" #hash;T;[o; ;[I"#Returns the integer hash code.;T@S; ; i; I"Methods for Comparing;To;;;;[o;;[I"{#<=>}[#method-i-3C-3D-3E];T;[o; ;[I"Returns -1, 0, or 1 ;TI"Fas +self+ is less than, equal to, or greater than a given object.;To;;[I"{#==}[#method-i-3D-3D];T;[o; ;[I"BReturns whether each element in +self+ is == to the ;TI"-corresponding element in a given object.;To;;[I" #eql?;T;[o; ;[I"RReturns whether each element in +self+ is eql? to the corresponding ;TI"element in a given object.;T@S; ; i; I"Methods for Fetching;T@o; ;[I"(These methods do not modify +self+.;T@o;;;;[ o;;[I"#[];T;[o; ;[I""Returns one or more elements.;To;;[I" #fetch;T;[o; ;[I"+Returns the element at a given offset.;To;;[I" #first;T;[o; ;[I"*Returns one or more leading elements.;To;;[I" #last;T;[o; ;[I"+Returns one or more trailing elements.;To;;[I" #max;T;[o; ;[I"2Returns one or more maximum-valued elements, ;TI"4as determined by <=> or a given block.;To;;[I" #max;T;[o; ;[I"2Returns one or more minimum-valued elements, ;TI"4as determined by <=> or a given block.;To;;[I" #minmax;T;[o; ;[I"=Returns the minimum-valued and maximum-valued elements, ;TI"4as determined by <=> or a given block.;To;;[I" #assoc;T;[o; ;[I"0Returns the first element that is an array ;TI"4whose first element == a given object.;To;;[I" #rassoc;T;[o; ;[I"0Returns the first element that is an array ;TI"5whose second element == a given object.;To;;[I"#at;T;[o; ;[I"+Returns the element at a given offset.;To;;[I"#values_at;T;[o; ;[I"+Returns the elements at given offsets.;To;;[I" #dig;T;[o; ;[I"*Returns the object in nested objects ;TI"Athat is specified by a given index and additional arguments.;To;;[I" #drop;T;[o; ;[I">Returns trailing elements as determined by a given index.;To;;[I" #take;T;[o; ;[I"=Returns leading elements as determined by a given index.;To;;[I"#drop_while;T;[o; ;[I">Returns trailing elements as determined by a given block.;To;;[I"#take_while;T;[o; ;[I"=Returns leading elements as determined by a given block.;To;;[I" #slice;T;[o; ;[I"DReturns consecutive elements as determined by a given argument.;To;;[I" #sort;T;[o; ;[I"RReturns all elements in an order determined by <=> or a given block.;To;;[I" #reverse;T;[o; ;[I"+Returns all elements in reverse order.;To;;[I" #compact;T;[o; ;[I"8Returns an array containing all non-+nil+ elements.;To;;[I"#select, #filter;T;[o; ;[I"DReturns an array containing elements selected by a given block.;To;;[I" #uniq;T;[o; ;[I"8Returns an array containing non-duplicate elements.;To;;[I" #rotate;T;[o; ;[I"FReturns all elements with some rotated from one end to the other.;To;;[I" #bsearch;T;[o; ;[I"5Returns an element selected via a binary search ;TI"$as determined by a given block.;To;;[I"#bsearch_index;T;[o; ;[I"BReturns the index of an element selected via a binary search ;TI"$as determined by a given block.;To;;[I" #sample;T;[o; ;[I")Returns one or more random elements.;To;;[I" #shuffle;T;[o; ;[I"(Returns elements in a random order.;T@S; ; i; I"Methods for Assigning;T@o; ;[I"?These methods add, replace, or reorder elements in +self+.;T@o;;;;[o;;[I" #[]=;T;[o; ;[I"4Assigns specified elements with a given object.;To;;[I"#push, #append, #<<;T;[o; ;[I"Appends trailing elements.;To;;[I"#unshift, #prepend;T;[o; ;[I"Prepends leading elements.;To;;[I" #insert;T;[o; ;[I"HInserts given objects at a given offset; does not replace elements.;To;;[I" #concat;T;[o; ;[I",Appends all elements from given arrays.;To;;[I" #fill;T;[o; ;[I"8Replaces specified elements with specified objects.;To;;[I" #replace;T;[o; ;[I"FReplaces the content of +self+ with the content of a given array.;To;;[I"#reverse!;T;[o; ;[I"0Replaces +self+ with its elements reversed.;To;;[I" #rotate!;T;[o; ;[I"/Replaces +self+ with its elements rotated.;To;;[I"#shuffle!;T;[o; ;[I"7Replaces +self+ with its elements in random order.;To;;[I" #sort!;T;[o; ;[I"/Replaces +self+ with its elements sorted, ;TI"4as determined by <=> or a given block.;To;;[I"#sort_by!;T;[o; ;[I"NReplaces +self+ with its elements sorted, as determined by a given block.;T@S; ; i; I"Methods for Deleting;T@o; ;[I"8Each of these methods removes elements from +self+:;T@o;;;;[o;;[I" #pop;T;[o; ;[I"*Removes and returns the last element.;To;;[I" #shift;T;[o; ;[I"+Removes and returns the first element.;To;;[I"#compact!;T;[o; ;[I"$Removes all non-+nil+ elements.;To;;[I" #delete;T;[o; ;[I".Removes elements equal to a given object.;To;;[I"#delete_at;T;[o; ;[I"+Removes the element at a given offset.;To;;[I"#delete_if;T;[o; ;[I"1Removes elements specified by a given block.;To;;[I" #keep_if;T;[o; ;[I"5Removes elements not specified by a given block.;To;;[I" #reject!;T;[o; ;[I"1Removes elements specified by a given block.;To;;[I"#select!, #filter!;T;[o; ;[I"5Removes elements not specified by a given block.;To;;[I" #slice!;T;[o; ;[I"0Removes and returns a sequence of elements.;To;;[I" #uniq!;T;[o; ;[I"Removes duplicates.;T@S; ; i; I"Methods for Combining;T@o;;;;[ o;;[I"{#&}[#method-i-26];T;[o; ;[I"QReturns an array containing elements found both in +self+ and a given array.;To;;[I"#intersection;T;[o; ;[I"?Returns an array containing elements found both in +self+ ;TI"and in each given array.;To;;[I"#+;T;[o; ;[I"bReturns an array containing all elements of +self+ followed by all elements of a given array.;To;;[I"#-;T;[o; ;[I"]Returns an array containiing all elements of +self+ that are not found in a given array.;To;;[I"{#|}[#method-i-7C];T;[o; ;[I"[Returns an array containing all elements of +self+ and all elements of a given array, ;TI"duplicates removed.;To;;[I" #union;T;[o; ;[I"ZReturns an array containing all elements of +self+ and all elements of given arrays, ;TI"duplicates removed.;To;;[I"#difference;T;[o; ;[I"KReturns an array containing all elements of +self+ that are not found ;TI"!in any of the given arrays..;To;;[I" #product;T;[o; ;[I"QReturns or yields all combinations of elements from +self+ and given arrays.;T@S; ; i; I"Methods for Iterating;T@o;;;;[ o;;[I" #each;T;[o; ;[I"*Passes each element to a given block.;To;;[I"#reverse_each;T;[o; ;[I"=Passes each element, in reverse order, to a given block.;To;;[I"#each_index;T;[o; ;[I"0Passes each element index to a given block.;To;;[I" #cycle;T;[o; ;[I"@Calls a given block with each element, then does so again, ;TI"1for a specified number of times, or forever.;To;;[I"#combination;T;[o; ;[I"BCalls a given block with combinations of elements of +self+; ;TI"@a combination does not use the same element more than once.;To;;[I"#permutation;T;[o; ;[I"BCalls a given block with permutations of elements of +self+; ;TI"@a permutation does not use the same element more than once.;To;;[I"#repeated_combination;T;[o; ;[I"BCalls a given block with combinations of elements of +self+; ;TI";a combination may use the same element more than once.;To;;[I"#repeated_permutation;T;[o; ;[I"BCalls a given block with permutations of elements of +self+; ;TI";a permutation may use the same element more than once.;T@S; ; i; I"Methods for Converting;T@o;;;;[o;;[I"#map, #collect;T;[o; ;[I"IReturns an array containing the block return-value for each element.;To;;[I"#map!, #collect!;T;[o; ;[I"5Replaces each element with a block return-value.;To;;[I" #flatten;T;[o; ;[I"?Returns an array that is a recursive flattening of +self+.;To;;[I"#flatten!;T;[o; ;[I"LReplaces each nested array in +self+ with the elements from that array.;To;;[I"#inspect, #to_s;T;[o; ;[I"2Returns a new String containing the elements.;To;;[I" #join;T;[o; ;[I"PReturns a newsString containing the elements joined by the field separator.;To;;[I" #to_a;T;[o; ;[I";Returns +self+ or a new array containing all elements.;To;;[I" #to_ary;T;[o; ;[I"Returns +self+.;To;;[I" #to_h;T;[o; ;[I"1Returns a new hash formed from the elements.;To;;[I"#transpose;T;[o; ;[I"9Transposes +self+, which must be an array of arrays.;To;;[I" #zip;T;[o; ;[I"GReturns a new array of arrays containing +self+ and given arrays; ;TI"!follow the link for details.;T@S; ; i; I"Other Methods;T@o;;;;[ o;;[I"#*;T;[o; ;[I""Returns one of the following:;To;;;;[o;;0;[o; ;[I"FWith integer argument +n+, a new array that is the concatenation ;TI"of +n+ copies of +self+.;To;;0;[o; ;[I"PWith string argument +field_separator+, a new string that is equivalent to ;TI"$join(field_separator).;To;;[I" #abbrev;T;[o; ;[I">Returns a hash of unambiguous abbreviations for elements.;To;;[I" #pack;T;[o; ;[I"/Packs the elements into a binary sequence.;To;;[I" #sum;T;[o; ;[I"OReturns a sum of elements according to either + or a given block.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0o;;[;I" array.rb;T;0o;;[;I"lib/abbrev.rb;T;0o;;[;I"lib/racc/compat.rb;T;0o;;[;I"lib/shellwords.rb;T;0o;;[o; ;[I"for pack.c;T;I" pack.rb;T;0;0;0[[[[I"Enumerable;To;;[;@;0I" array.c;T[[I" class;T[[: public[[:protected[[: private[[I"[];T@[I"new;T@[I"try_convert;T@[I" instance;T[[;[[;[[;[I"&;T@[I"*;T@[I"+;T@[I"-;T@[I"<<;T@[I"<=>;T@[I"==;T@[I"[];T@[I"[]=;T@[I" abbrev;TI"lib/abbrev.rb;T[I" all?;T@[I" any?;T@[I" append;T@[I" assoc;T@[I"at;T@[I" bsearch;T@[I"bsearch_index;T@[I" clear;T@[I" collect;T@[I" collect!;T@[I"combination;T@[I" compact;T@[I" compact!;T@[I" concat;T@[I" count;T@[I" cycle;T@[I"deconstruct;T@[I" delete;T@[I"delete_at;T@[I"delete_if;T@[I"difference;T@[I"dig;T@[I" drop;T@[I"drop_while;T@[I" each;T@[I"each_index;T@[I" empty?;T@[I" eql?;T@[I" fetch;T@[I" fill;T@[I" filter;T@[I" filter!;T@[I"find_index;T@[I" first;T@[I" flatten;T@[I" flatten!;T@[I" hash;T@[I" include?;T@[I" index;T@[I"initialize_copy;T@[I" insert;T@[I" inspect;T@[I"intersect?;T@[I"intersection;T@[I" join;T@[I" keep_if;T@[I" last;T@[I" length;T@[I"map;T@[I" map!;T@[I"max;T@[I"min;T@[I" minmax;T@[I" none?;T@[I" one?;T@[I" pack;TI" pack.rb;T[I"permutation;T@[I"pop;T@[I" prepend;T@[I" product;T@[I" push;T@[I" rassoc;T@[I" reject;T@[I" reject!;T@[I"repeated_combination;T@[I"repeated_permutation;T@[I" replace;T@[I" reverse;T@[I" reverse!;T@[I"reverse_each;T@[I" rindex;T@[I" rotate;T@[I" rotate!;T@[I" sample;TI" array.rb;T[I" select;T@[I" select!;T@[I"shelljoin;TI"lib/shellwords.rb;T[I" shift;T@[I" shuffle;T@[I" shuffle!;T@[I" size;T@[I" slice;T@[I" slice!;T@[I" sort;T@[I" sort!;T@[I" sort_by!;T@[I"sum;T@[I" take;T@[I"take_while;T@[I" to_a;T@[I" to_ary;T@[I" to_h;T@[I" to_s;T@[I"transpose;T@[I" union;T@[I" uniq;T@[I" uniq!;T@[I" unshift;T@[I"values_at;T@[I"zip;T@[I"|;T@[[U:RDoc::Context::Section[i0o;;[;0;0[I" array.c;TI" array.rb;TI"lib/abbrev.rb;TI"lib/csv/core_ext/array.rb;TI"lib/mkmf.rb;TI"lib/pp.rb;TI"lib/racc/compat.rb;TI"lib/shellwords.rb;TI" pack.rb;T@cRDoc::TopLevelPK]I4yy filter-i.rinu[U:RDoc::AnyMethod[iI" filter:ETI"Array#filter;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"=Calls the block, if given, with each element of +self+; ;TI">returns a new \Array containing those elements of +self+ ;TI"0for which the block returns a truthy value:;To:RDoc::Markup::Verbatim; [I" a = [:foo, 'bar', 2, :bam] ;TI">a1 = a.select {|element| element.to_s.start_with?('b') } ;TI"a1 # => ["bar", :bam] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I" a = [:foo, 'bar', 2, :bam] ;TI"@a.select # => # ;T; 0o; ; [I"/Array#filter is an alias for Array#select.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[[I" map!;To;; [; I"lib/racc/compat.rb;T;0I"();T@FI" Array;TcRDoc::NormalClass0[@'FI" select;TPK][# sample-i.rinu[U:RDoc::AnyMethod[iI" sample:ETI"Array#sample;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I")Returns random elements from +self+.;To:RDoc::Markup::BlankLineo; ; [I"GWhen no arguments are given, returns a random element from +self+:;To:RDoc::Markup::Verbatim; [I")a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ;TI"a.sample # => 3 ;TI"a.sample # => 8 ;T: @format0o; ; [I"'If +self+ is empty, returns +nil+.;T@o; ; [I"LWhen argument +n+ is given, returns a new \Array containing +n+ random ;TI"elements from +self+:;To; ; [I" a.sample(3) # => [8, 9, 2] ;TI"*a.sample(6) # => [9, 6, 10, 3, 1, 4] ;T; 0o; ; [I"3Returns no more than a.size elements ;TI"0(because no new duplicates are introduced):;To; ; [I"?a.sample(a.size * 2) # => [6, 4, 1, 8, 5, 9, 10, 2, 3, 7] ;T; 0o; ; [I"'But +self+ may contain duplicates:;To; ; [I"a = [1, 1, 1, 2, 2, 3] ;TI"2a.sample(a.size * 2) # => [1, 1, 3, 2, 1, 2] ;T; 0o; ; [I" 6 ;TI":a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2];T; 0: @fileI" array.rb;T:0@omit_headings_from_table_of_contents_below0I"Warray.sample(random: Random) -> object array.sample(n, random: Random) -> new_ary ;T0[I"((n = (ary = false), random: Random);T@=FI" Array;TcRDoc::NormalClass00PK]dVshuffle%21-i.rinu[U:RDoc::AnyMethod[iI" shuffle!:ETI"Array#shuffle!;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I".Shuffles the elements of +self+ in place.;To:RDoc::Markup::Verbatim; [I"!a = [1, 2, 3] #=> [1, 2, 3] ;TI"!a.shuffle! #=> [2, 3, 1] ;TI"!a #=> [2, 3, 1] ;T: @format0o; ; [I"PThe optional +random+ argument will be used as the random number generator:;To; ; [I"5a.shuffle!(random: Random.new(1)) #=> [1, 3, 2];T; 0: @fileI" array.rb;T:0@omit_headings_from_table_of_contents_below0I"-array.shuffle!(random: Random) -> array ;T0[I"(random: Random);T@FI" Array;TcRDoc::NormalClass00PK]uD%combination-i.rinu[U:RDoc::AnyMethod[iI"combination:ETI"Array#combination;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ICalls the block, if given, with combinations of elements of +self+; ;TI"@returns +self+. The order of combinations is indeterminate.;To:RDoc::Markup::BlankLineo; ; [I"_When a block and an in-range positive \Integer argument +n+ (0 < n <= self.size) ;TI"Jare given, calls the block with all +n+-tuple combinations of +self+.;T@o; ; [I" Example:;To:RDoc::Markup::Verbatim; [I"a = [0, 1, 2] ;TI"5a.combination(2) {|combination| p combination } ;T: @format0o; ; [I" Output:;To; ; [I" [0, 1] ;TI" [0, 2] ;TI" [1, 2] ;T; 0o; ; [I"Another example:;To; ; [I"a = [0, 1, 2] ;TI"5a.combination(3) {|combination| p combination } ;T; 0o; ; [I" Output:;To; ; [I"[0, 1, 2] ;T; 0o; ; [I"DWhen +n+ is zero, calls the block once with a new empty \Array:;To; ; [I"a = [0, 1, 2] ;TI":a1 = a.combination(0) {|combination| p combination } ;T; 0o; ; [I" Output:;To; ; [I"[] ;T; 0o; ; [I"LWhen +n+ is out of range (negative or larger than self.size), ;TI"does not call the block:;To; ; [I"a = [0, 1, 2] ;TI"=a.combination(-1) {|combination| fail 'Cannot happen' } ;TI" #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Zarray.combination(n) {|element| ... } -> self array.combination(n) -> new_enumerator ;T0[I" (p1);T@MFI" Array;TcRDoc::NormalClass00PK]boorepeated_permutation-i.rinu[U:RDoc::AnyMethod[iI"repeated_permutation:ETI"Array#repeated_permutation;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"]Calls the block with each repeated permutation of length +n+ of the elements of +self+; ;TI"$each permutation is an \Array; ;TI"Dreturns +self+. The order of the permutations is indeterminate.;To:RDoc::Markup::BlankLineo; ; [I"\When a block and a positive \Integer argument +n+ are given, calls the block with each ;TI"?+n+-tuple repeated permutation of the elements of +self+. ;TI"9The number of permutations is self.size**n.;T@o; ; [I" +n+ = 1:;To:RDoc::Markup::Verbatim; [I"a = [0, 1, 2] ;TI">a.repeated_permutation(1) {|permutation| p permutation } ;T: @format0o; ; [I" Output:;To; ; [I" [0] ;TI" [1] ;TI" [2] ;T; 0o; ; [I" +n+ = 2:;To; ; [I">a.repeated_permutation(2) {|permutation| p permutation } ;T; 0o; ; [I" Output:;To; ; [I" [0, 0] ;TI" [0, 1] ;TI" [0, 2] ;TI" [1, 0] ;TI" [1, 1] ;TI" [1, 2] ;TI" [2, 0] ;TI" [2, 1] ;TI" [2, 2] ;T; 0o; ; [I"?If +n+ is zero, calls the block once with an empty \Array.;T@o; ; [I"1If +n+ is negative, does not call the block:;To; ; [I"Fa.repeated_permutation(-1) {|permutation| fail 'Cannot happen' } ;T; 0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [0, 1, 2] ;TI"La.repeated_permutation(2) # => # ;T; 0o; ; [I"LUsing Enumerators, it's convenient to show the permutations and counts ;TI"for some values of +n+:;To; ; [I"#e = a.repeated_permutation(0) ;TI"e.size # => 1 ;TI"e.to_a # => [[]] ;TI"#e = a.repeated_permutation(1) ;TI"e.size # => 3 ;TI"!e.to_a # => [[0], [1], [2]] ;TI"#e = a.repeated_permutation(2) ;TI"e.size # => 9 ;TI"Ye.to_a # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"parray.repeated_permutation(n) {|permutation| ... } -> self array.repeated_permutation(n) -> new_enumerator ;T0[I" (p1);T@XFI" Array;TcRDoc::NormalClass00PK]^Ql replace-i.rinu[U:RDoc::AnyMethod[iI" replace:ETI"Array#replace;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"VReplaces the content of +self+ with the content of +other_array+; returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"6a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1);T@FI" Array;TcRDoc::NormalClass0[@FI"initialize_copy;TPK];; inspect-i.rinu[U:RDoc::AnyMethod[iI" inspect:ETI"Array#inspect;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"HReturns the new \String formed by calling method #inspect ;TI"on each array element:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI")a.inspect # => "[:foo, \"bar\", 2]" ;T: @format0o; ; [I".Array#to_s is an alias for Array#inspect.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"!array.inspect -> new_string ;T0[[I" to_s;T@ I"();T@FI" Array;TcRDoc::NormalClass00PK]X$BH take-i.rinu[U:RDoc::AnyMethod[iI" take:ETI"Array#take;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"FReturns a new \Array containing the first +n+ element of +self+, ;TI"+where +n+ is a non-negative \Integer; ;TI"does not modify +self+.;To:RDoc::Markup::BlankLineo; ; [I"Examples:;To:RDoc::Markup::Verbatim; [ I"a = [0, 1, 2, 3, 4, 5] ;TI"a.take(1) # => [0] ;TI"a.take(2) # => [0, 1] ;TI"(a.take(50) # => [0, 1, 2, 3, 4, 5] ;TI"a # => [0, 1, 2, 3, 4, 5];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I" array.take(n) -> new_array ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]mgB clear-i.rinu[U:RDoc::AnyMethod[iI" clear:ETI"Array#clear;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"&Removes all elements from +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.clear # => [];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array.clear -> self ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]/& shift-i.rinu[U:RDoc::AnyMethod[iI" shift:ETI"Array#shift;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"*Removes and returns leading elements.;To:RDoc::Markup::BlankLineo; ; [I"FWhen no argument is given, removes and returns the first element:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.shift # => :foo ;TI"a # => ['bar', 2] ;T: @format0o; ; [I"&Returns +nil+ if +self+ is empty.;T@o; ; [I"SWhen positive \Integer argument +n+ is given, removes the first +n+ elements; ;TI",returns those elements in a new \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"#a.shift(2) # => [:foo, 'bar'] ;TI"a # => [2] ;T; 0o; ; [I"@If +n+ is as large as or larger than self.length, ;TI"Bremoves all elements; returns those elements in a new \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"&a.shift(3) # => [:foo, 'bar', 2] ;T; 0o; ; [I"FIf +n+ is zero, returns a new empty \Array; +self+ is unmodified.;T@o; ; [I"$Related: #push, #pop, #unshift.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I">array.shift -> object or nil array.shift(n) -> new_array ;T0[I" (*args);T@1FI" Array;TcRDoc::NormalClass00PK]< to_a-i.rinu[U:RDoc::AnyMethod[iI" to_a:ETI"Array#to_a;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I":When +self+ is an instance of \Array, returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI""a.to_a # => [:foo, "bar", 2] ;T: @format0o; ; [I"GOtherwise, returns a new \Array containing the elements of +self+:;To; ; [ I" class MyArray < Array; end ;TI",a = MyArray.new(['foo', 'bar', 'two']) ;TI"&a.instance_of?(Array) # => false ;TI"!a.kind_of?(Array) # => true ;TI"a1 = a.to_a ;TI"#a1 # => ["foo", "bar", "two"] ;TI"&a1.class # => Array # Not MyArray;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"to_a -> self or new_array ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK] deconstruct-i.rinu[U:RDoc::AnyMethod[iI"deconstruct:ETI"Array#deconstruct;TF: privateo:RDoc::Markup::Document: @parts[: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI" Array;TcRDoc::NormalClass00PK]C++ to_ary-i.rinu[U:RDoc::AnyMethod[iI" to_ary:ETI"Array#to_ary;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Returns +self+.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array.to_ary -> self ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK] tt first-i.rinu[U:RDoc::AnyMethod[iI" first:ETI"Array#first;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I":Returns elements from +self+; does not modify +self+.;To:RDoc::Markup::BlankLineo; ; [I":When no argument is given, returns the first element:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.first # => :foo ;TI"a # => [:foo, "bar", 2] ;T: @format0o; ; [I"'If +self+ is empty, returns +nil+.;T@o; ; [I"7When non-negative \Integer argument +n+ is given, ;TI"4returns the first +n+ elements in a new \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"#a.first(2) # => [:foo, "bar"] ;T; 0o; ; [I"7If n >= array.size, returns all elements:;To; ; [I"a = [:foo, 'bar', 2] ;TI"'a.first(50) # => [:foo, "bar", 2] ;T; 0o; ; [I"4If n == 0 returns an new empty \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.first(0) # [] ;T; 0o; ; [I"Related: #last.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I">array.first -> object or nil array.first(n) -> new_array ;T0[I" (*args);T@3FI" Array;TcRDoc::NormalClass00PK]YA %5b%5d-c.rinu[U:RDoc::AnyMethod[iI"[]:ETI"Array::[];TT: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I":Returns a new array populated with the given objects.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"2Array.[]( 1, 'a', /^A/) # => [1, "a", /^A/] ;TI"2Array[ 1, 'a', /^A/ ] # => [1, "a", /^A/] ;TI"1[ 1, 'a', /^A/ ] # => [1, "a", /^A/];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Array;TcRDoc::NormalClass00PK]M4HHpop-i.rinu[U:RDoc::AnyMethod[iI"pop:ETI"Array#pop;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"+Removes and returns trailing elements.;To:RDoc::Markup::BlankLineo; ; [I"8When no argument is given and +self+ is not empty, ;TI"*removes and returns the last element:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.pop # => 2 ;TI"a # => [:foo, "bar"] ;T: @format0o; ; [I")Returns +nil+ if the array is empty.;T@o; ; [I"IWhen a non-negative \Integer argument +n+ is given and is in range, ;TI"?removes and returns the last +n+ elements in a new \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.pop(2) # => ["bar", 2] ;T; 0o; ; [I"*If +n+ is positive and out of range, ;TI"&removes and returns all elements:;To; ; [I"a = [:foo, 'bar', 2] ;TI"%a.pop(50) # => [:foo, "bar", 2] ;T; 0o; ; [I"&Related: #push, #shift, #unshift.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I":array.pop -> object or nil array.pop(n) -> new_array ;T0[I" (*args);T@.FI" Array;TcRDoc::NormalClass00PK]@| rotate-i.rinu[U:RDoc::AnyMethod[iI" rotate:ETI"Array#rotate;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I";Returns a new \Array formed from +self+ with elements ;TI"'rotated from one end to the other.;To:RDoc::Markup::BlankLineo; ; [I"GWhen no argument given, returns a new \Array that is like +self+, ;TI"Iexcept that the first element has been rotated to the last position:;To:RDoc::Markup::Verbatim; [I"!a = [:foo, 'bar', 2, 'bar'] ;TI"a1 = a.rotate ;TI"%a1 # => ["bar", 2, "bar", :foo] ;T: @format0o; ; [I"1When given a non-negative \Integer +count+, ;TI"Vreturns a new \Array with +count+ elements rotated from the beginning to the end:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.rotate(2) ;TI"a1 # => [2, :foo, "bar"] ;T; 0o; ; [I"HIf +count+ is large, uses count % array.size as the count:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.rotate(20) ;TI"a1 # => [2, :foo, "bar"] ;T; 0o; ; [I">If +count+ is zero, returns a copy of +self+, unmodified:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.rotate(0) ;TI"a1 # => [:foo, "bar", 2] ;T; 0o; ; [I"PWhen given a negative \Integer +count+, rotates in the opposite direction, ;TI"from end to beginning:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.rotate(-2) ;TI"a1 # => ["bar", 2, :foo] ;T; 0o; ; [I"XIf +count+ is small (far from zero), uses count % array.size as the count:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.rotate(-5) ;TI"a1 # => ["bar", 2, :foo];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"@array.rotate -> new_array array.rotate(count) -> new_array ;T0[I" (*args);T@CFI" Array;TcRDoc::NormalClass00PK]   keep_if-i.rinu[U:RDoc::AnyMethod[iI" keep_if:ETI"Array#keep_if;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"HRetains those elements for which the block returns a truthy value; ;TI"0deletes all other elements; returns +self+:;To:RDoc::Markup::Verbatim; [I" a = [:foo, 'bar', 2, :bam] ;TI"Ma.keep_if {|element| element.to_s.start_with?('b') } # => ["bar", :bam] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I" a = [:foo, 'bar', 2, :bam] ;TI"Aa.keep_if # => #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Marray.keep_if {|element| ... } -> self array.keep_if -> new_enumeration ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]'jbsearch_index-i.rinu[U:RDoc::AnyMethod[iI"bsearch_index:ETI"Array#bsearch_index;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"6Searches +self+ as described at method #bsearch, ;TI"Pbut returns the _index_ of the found element instead of the element itself.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"barray.bsearch_index {|element| ... } -> integer or nil array.bsearch_index -> new_enumerator ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]ނ fetch-i.rinu[U:RDoc::AnyMethod[iI" fetch:ETI"Array#fetch;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I",Returns the element at offset +index+.;To:RDoc::Markup::BlankLineo; ; [I"0With the single \Integer argument +index+, ;TI"+returns the element at offset +index+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.fetch(1) # => "bar" ;T: @format0o; ; [I">If +index+ is negative, counts from the end of the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.fetch(-1) # => 2 ;TI"a.fetch(-2) # => "bar" ;T; 0o; ; [I"1With arguments +index+ and +default_value+, ;TI"Areturns the element at offset +index+ if index is in range, ;TI"'otherwise returns +default_value+:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a.fetch(1, nil) # => "bar" ;T; 0o; ; [I"(With argument +index+ and a block, ;TI"@returns the element at offset +index+ if index is in range ;TI"f(and the block is not called); otherwise calls the block with index and returns its return value:;T@o; ; [I"a = [:foo, 'bar', 2] ;TI" "bar" ;TI"Da.fetch(50) {|index| "Value for #{index}" } # => "Value for 50";T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"}array.fetch(index) -> element array.fetch(index, default_value) -> element array.fetch(index) {|index| ... } -> element ;T0[I"(p1, p2 = v2);T@2FI" Array;TcRDoc::NormalClass00PK]ܢ shuffle-i.rinu[U:RDoc::AnyMethod[iI" shuffle:ETI"Array#shuffle;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I":Returns a new array with elements of +self+ shuffled.;To:RDoc::Markup::Verbatim; [I"!a = [1, 2, 3] #=> [1, 2, 3] ;TI"!a.shuffle #=> [2, 3, 1] ;TI"!a #=> [1, 2, 3] ;T: @format0o; ; [I"PThe optional +random+ argument will be used as the random number generator:;To; ; [I"4a.shuffle(random: Random.new(1)) #=> [1, 3, 2];T; 0: @fileI" array.rb;T:0@omit_headings_from_table_of_contents_below0I".array.shuffle(random: Random) -> new_ary ;T0[I"(random: Random);T@FI" Array;TcRDoc::NormalClass00PK]4 eql%3f-i.rinu[U:RDoc::AnyMethod[iI" eql?:ETI"Array#eql?;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"CReturns +true+ if +self+ and +other_array+ are the same size, ;TI"Pand if, for each index +i+ in +self+, self[i].eql? other_array[i]:;To:RDoc::Markup::Verbatim; [I"a0 = [:foo, 'bar', 2] ;TI"a1 = [:foo, 'bar', 2] ;TI"a1.eql?(a0) # => true ;T: @format0o; ; [I" Otherwise, returns +false+.;To:RDoc::Markup::BlankLineo; ; [I"GThis method is different from method {Array#==}[#method-i-3D-3D], ;TI"4which compares using method Object#==.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"-array.eql? other_array -> true or false ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK],  new-c.rinu[U:RDoc::AnyMethod[iI"new:ETI"Array::new;TT: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Returns a new \Array.;To:RDoc::Markup::BlankLineo; ; [I"GWith no block and no arguments, returns a new empty \Array object.;T@o; ; [I"9With no block and a single \Array argument +array+, ;TI".returns a new \Array formed from +array+:;To:RDoc::Markup::Verbatim; [I"%a = Array.new([:foo, 'bar', 2]) ;TI"a.class # => Array ;TI"a # => [:foo, "bar", 2] ;T: @format0o; ; [I":With no block and a single \Integer argument +size+, ;TI",returns a new \Array of the given size ;TI""whose elements are all +nil+:;To; ; [I"a = Array.new(3) ;TI"a # => [nil, nil, nil] ;T; 0o; ; [I"=With no block and arguments +size+ and +default_value+, ;TI"*returns an \Array of the given size; ;TI"/each element is that same +default_value+:;To; ; [I"a = Array.new(3, 'x') ;TI"a # => ['x', 'x', 'x'] ;T; 0o; ; [ I"'With a block and argument +size+, ;TI"*returns an \Array of the given size; ;TI"?the block is called with each successive integer +index+; ;TI"Ethe element for that +index+ is the return value from the block:;To; ; [I"4a = Array.new(3) {|index| "Element #{index}" } ;TI"4a # => ["Element 0", "Element 1", "Element 2"] ;T; 0o; ; [I"0Raises ArgumentError if +size+ is negative.;T@o; ; [I"#With a block and no argument, ;TI"or a single argument +0+, ;TI"6ignores the block and returns a new empty \Array.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Array.new -> new_empty_array Array.new(array) -> new_array Array.new(size) -> new_array Array.new(size, default_value) -> new_array Array.new(size) {|index| ... } -> new_array ;T0[I"(p1 = v1, p2 = v2);T@?FI" Array;TcRDoc::NormalClass00PK]l$$rotate%21-i.rinu[U:RDoc::AnyMethod[iI" rotate!:ETI"Array#rotate!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"ZRotates +self+ in place by moving elements from one end to the other; returns +self+.;To:RDoc::Markup::BlankLineo; ; [I"LWhen no argument given, rotates the first element to the last position:;To:RDoc::Markup::Verbatim; [I"!a = [:foo, 'bar', 2, 'bar'] ;TI",a.rotate! # => ["bar", 2, "bar", :foo] ;T: @format0o; ; [I"1When given a non-negative \Integer +count+, ;TI" [2, :foo, "bar"] ;T; 0o; ; [I"HIf +count+ is large, uses count % array.size as the count:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.rotate!(20) ;TI"a # => [2, :foo, "bar"] ;T; 0o; ; [I"3If +count+ is zero, returns +self+ unmodified:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.rotate!(0) ;TI"a # => [:foo, "bar", 2] ;T; 0o; ; [I"OWhen given a negative Integer +count+, rotates in the opposite direction, ;TI"from end to beginning:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.rotate!(-2) ;TI"a # => ["bar", 2, :foo] ;T; 0o; ; [I"XIf +count+ is small (far from zero), uses count % array.size as the count:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.rotate!(-5) ;TI"a # => ["bar", 2, :foo];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"8array.rotate! -> self array.rotate!(count) -> self ;T0[I" (*args);T@@FI" Array;TcRDoc::NormalClass00PK]$ rindex-i.rinu[U:RDoc::AnyMethod[iI" rindex:ETI"Array#rindex;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"PReturns the index of the last element for which object == element.;To:RDoc::Markup::BlankLineo; ; [I"dWhen argument +object+ is given but no block, returns the index of the last such element found:;To:RDoc::Markup::Verbatim; [I"!a = [:foo, 'bar', 2, 'bar'] ;TI"a.rindex('bar') # => 3 ;T: @format0o; ; [I"+Returns +nil+ if no such object found.;T@o; ; [I"ZWhen a block is given but no argument, calls the block with each successive element; ;TI"Vreturns the index of the last element for which the block returns a truthy value:;To; ; [I"!a = [:foo, 'bar', 2, 'bar'] ;TI"3a.rindex {|element| element == 'bar' } # => 3 ;T; 0o; ; [I"=Returns +nil+ if the block never returns a truthy value.;T@o; ; [I"NWhen neither an argument nor a block is given, returns a new \Enumerator:;T@o; ; [ I"!a = [:foo, 'bar', 2, 'bar'] ;TI"e = a.rindex ;TI":e # => # ;TI"1e.each {|element| element == 'bar' } # => 3 ;T; 0o; ; [I"Related: #index.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"{array.rindex(object) -> integer or nil array.rindex {|element| ... } -> integer or nil array.rindex -> new_enumerator ;T0[I" (*args);T@0FI" Array;TcRDoc::NormalClass00PK]4ԕ sort-i.rinu[U:RDoc::AnyMethod[iI" sort:ETI"Array#sort;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GReturns a new \Array whose elements are those from +self+, sorted.;To:RDoc::Markup::BlankLineo; ; [I"BWith no block, compares elements using operator <=> ;TI"(see Comparable):;To:RDoc::Markup::Verbatim; [ I"#a = 'abcde'.split('').shuffle ;TI"&a # => ["e", "b", "d", "a", "c"] ;TI"a1 = a.sort ;TI"'a1 # => ["a", "b", "c", "d", "e"] ;T: @format0o; ; [I";With a block, calls the block with each element pair; ;TI"Kfor each element pair +a+ and +b+, the block should return an integer:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"(Negative when +b+ is to follow +a+.;To;;0; [o; ; [I"*Zero when +a+ and +b+ are equivalent.;To;;0; [o; ; [I"(Positive when +a+ is to follow +b+.;T@o; ; [I" Example:;To; ; [ I"#a = 'abcde'.split('').shuffle ;TI"&a # => ["e", "b", "d", "a", "c"] ;TI"#a1 = a.sort {|a, b| a <=> b } ;TI"'a1 # => ["a", "b", "c", "d", "e"] ;TI"#a2 = a.sort {|a, b| b <=> a } ;TI"'a2 # => ["e", "d", "c", "b", "a"] ;T; 0o; ; [I"NWhen the block returns zero, the order for +a+ and +b+ is indeterminate, ;TI"and may be unstable:;To; ; [ I"#a = 'abcde'.split('').shuffle ;TI"&a # => ["e", "b", "d", "a", "c"] ;TI"a1 = a.sort {|a, b| 0 } ;TI"(a1 # => ["c", "e", "b", "d", "a"] ;T; 0o; ; [I"!Related: Enumerable#sort_by.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Carray.sort -> new_array array.sort {|a, b| ... } -> new_array ;T0[I"();T@FFI" Array;TcRDoc::NormalClass00PK]!Q SSreject%21-i.rinu[U:RDoc::AnyMethod[iI" reject!:ETI"Array#reject!;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"ERemoves each element for which the block returns a truthy value.;To:RDoc::Markup::BlankLineo; ; [I",Returns +self+ if any elements removed:;To:RDoc::Markup::Verbatim; [I"!a = [:foo, 'bar', 2, 'bat'] ;TI"Ia.reject! {|element| element.to_s.start_with?('b') } # => [:foo, 2] ;T: @format0o; ; [I"*Returns +nil+ if no elements removed.;T@o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [:foo, 'bar', 2] ;TI";a.reject! # => #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Sarray.reject! {|element| ... } -> self or nil array.reject! -> new_enumerator ;T0[I"();T@ FI" Array;TcRDoc::NormalClass00PK]itt none%3f-i.rinu[U:RDoc::AnyMethod[iI" none?:ETI"Array#none?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"CReturns +true+ if no element of +self+ meet a given criterion.;To:RDoc::Markup::BlankLineo; ; [I"[With no block given and no argument, returns +true+ if +self+ has no truthy elements, ;TI"+false+ otherwise:;To:RDoc::Markup::Verbatim; [I""[nil, false].none? # => true ;TI"&[nil, 0, false].none? # => false ;TI"[].none? # => true ;T: @format0o; ; [I"VWith a block given and no argument, calls the block with each element in +self+; ;TI"Lreturns +true+ if the block returns no truthy value, +false+ otherwise:;To; ; [I"8[0, 1, 2].none? {|element| element > 3 } # => true ;TI"9[0, 1, 2].none? {|element| element > 1 } # => false ;T; 0o; ; [I"bIf argument +obj+ is given, returns +true+ if obj.=== no element, +false+ otherwise:;To; ; [ I".['food', 'drink'].none?(/bar/) # => true ;TI"/['food', 'drink'].none?(/foo/) # => false ;TI"[].none?(/foo/) # => true ;TI""[0, 1, 2].none?(3) # => true ;TI"#[0, 1, 2].none?(1) # => false ;T; 0o; ; [I"Related: Enumerable#none?;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"rarray.none? -> true or false array.none? {|element| ... } -> true or false array.none?(obj) -> true or false ;T0[I" (*args);T@-FI" Array;TcRDoc::NormalClass00PK]Ym m pack-i.rinu[U:RDoc::AnyMethod[iI" pack:ETI"Array#pack;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"JPacks the contents of arr into a binary sequence according to ;TI"Dthe directives in aTemplateString (see the table below) ;TI"DDirectives ``A,'' ``a,'' and ``Z'' may be followed by a count, ;TI"Awhich gives the width of the resulting field. The remaining ;TI"Fdirectives also may take a count, indicating the number of array ;TI"6elements to convert. If the count is an asterisk ;TI"@(``*''), all remaining array elements will be ;TI"Econverted. Any of the directives ``sSiIlL'' may be ;TI"7followed by an underscore (``_'') or ;TI"Aexclamation mark (``!'') to use the underlying ;TI"Jplatform's native size for the specified type; otherwise, they use a ;TI"Cplatform-independent size. Spaces are ignored in the template ;TI"$string. See also String#unpack.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"a = [ "a", "b", "c" ] ;TI"n = [ 65, 66, 67 ] ;TI"(a.pack("A3A3A3") #=> "a b c " ;TI":a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000" ;TI""n.pack("ccc") #=> "ABC" ;T: @format0o; ; [ I"FIf aBufferString is specified and its capacity is enough, ;TI"2+pack+ uses it as the buffer and returns it. ;TI"NWhen the offset is specified by the beginning of aTemplateString, ;TI",the result is filled after the offset. ;TI"NIf original contents of aBufferString exists and it's longer than ;TI"Rthe offset, the rest of offsetOfBuffer are overwritten by the result. ;TI"AIf it's shorter, the gap is filled with ``\0''.;T@o; ; [I"*# packed data is appended by default ;TI"3[255].pack("C", buffer:"foo".b) #=> "foo\xFF" ;TI" ;TI"L# "@0" (offset 0) specifies that packed data is filled from beginning. ;TI"L# Also, original data after packed data is removed. ("oo" is removed.) ;TI"2[255].pack("@0C", buffer:"foo".b) #=> "\xFF" ;TI" ;TI"I# If the offset is bigger than the original length, \x00 is filled. ;TI"=[255].pack("@5C", buffer:"foo".b) #=> "foo\x00\x00\xFF" ;T; 0o; ; [I"LNote that ``buffer:'' option does not guarantee not to allocate memory ;TI"Hin +pack+. If the capacity of aBufferString is not enough, ;TI"+pack+ allocates memory.;T@o; ; [I"Directives for +pack+.;T@o; ; [`I"Integer | Array | ;TI"'Directive | Element | Meaning ;TI"R---------------------------------------------------------------------------- ;TI">C | Integer | 8-bit unsigned (unsigned char) ;TI"IS | Integer | 16-bit unsigned, native endian (uint16_t) ;TI"IL | Integer | 32-bit unsigned, native endian (uint32_t) ;TI"IQ | Integer | 64-bit unsigned, native endian (uint64_t) ;TI"QJ | Integer | pointer width unsigned, native endian (uintptr_t) ;TI"@ | | (J is available since Ruby 2.3.) ;TI" | | ;TI":c | Integer | 8-bit signed (signed char) ;TI"Fs | Integer | 16-bit signed, native endian (int16_t) ;TI"Fl | Integer | 32-bit signed, native endian (int32_t) ;TI"Fq | Integer | 64-bit signed, native endian (int64_t) ;TI"Nj | Integer | pointer width signed, native endian (intptr_t) ;TI"@ | | (j is available since Ruby 2.3.) ;TI" | | ;TI"=S_ S! | Integer | unsigned short, native endian ;TI";I I_ I! | Integer | unsigned int, native endian ;TI" s> S!> s!> | Integer | same as the directives without ">" except ;TI"*L> l> L!> l!> | | big endian ;TI" i!> | | (available since Ruby 1.9.3) ;TI"7Q> q> Q!> q!> | | "S>" is the same as "n" ;TI"7J> j> J!> j!> | | "L>" is the same as "N" ;TI" | | ;TI"IS< s< S!< s!< | Integer | same as the directives without "<" except ;TI"-L< l< L!< l!< | | little endian ;TI"D d | Float | double-precision, native format ;TI">F f | Float | single-precision, native format ;TI"IE | Float | double-precision, little-endian byte order ;TI"Ie | Float | single-precision, little-endian byte order ;TI"PG | Float | double-precision, network (big-endian) byte order ;TI"Pg | Float | single-precision, network (big-endian) byte order ;TI" ;TI"String | Array | ;TI"&Directive | Element | Meaning ;TI"Q--------------------------------------------------------------------------- ;TI"UA | String | arbitrary binary string (space padded, count is width) ;TI"Ta | String | arbitrary binary string (null padded, count is width) ;TI"NZ | String | same as ``a'', except that null is added with * ;TI"5B | String | bit string (MSB first) ;TI"5b | String | bit string (LSB first) ;TI"=H | String | hex string (high nibble first) ;TI" aBinaryString arr.pack( aTemplateString, buffer: aBufferString ) -> aBufferString ;T0[I"(fmt, buffer: nil);T@FI" Array;TcRDoc::NormalClass00PK]p#zz empty%3f-i.rinu[U:RDoc::AnyMethod[iI" empty?:ETI"Array#empty?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"@Returns +true+ if the count of elements in +self+ is zero, ;TI"+false+ otherwise.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"$array.empty? -> true or false ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]%26-i.rinu[U:RDoc::AnyMethod[iI"&:ETI" Array#&;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"bReturns a new \Array containing each element found in both +array+ and \Array +other_array+; ;TI"Dduplicates are omitted; items are compared using eql?:;To:RDoc::Markup::Verbatim; [I"'[0, 1, 2, 3] & [1, 2] # => [1, 2] ;TI"'[0, 1, 0, 1] & [0, 1] # => [0, 1] ;T: @format0o; ; [I""Preserves order from +array+:;To; ; [I"-[0, 1, 2] & [3, 2, 1, 0] # => [0, 1, 2] ;T; 0o; ; [I"!Related: Array#intersection.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"&array & other_array -> new_array ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]Djdd append-i.rinu[U:RDoc::AnyMethod[iI" append:ETI"Array#append;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Appends trailing elements.;To:RDoc::Markup::BlankLineo; ; [I"CAppends each argument in +objects+ to +self+; returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI":a.push(:baz, :bat) # => [:foo, "bar", 2, :baz, :bat] ;T: @format0o; ; [I"HAppends each argument as one element, even if it is another \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"-a1 = a.push([:baz, :bat], [:bam, :bad]) ;TI":a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]] ;T; 0o; ; [I".Array#append is an alias for \Array#push.;T@o; ; [I"%Related: #pop, #shift, #unshift.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@$FI" Array;TcRDoc::NormalClass0[@'FI" push;TPK] _%2a-i.rinu[U:RDoc::AnyMethod[iI"*:ETI" Array#*;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"7When non-negative argument \Integer +n+ is given, ;TI"Jreturns a new \Array built by concatenating the +n+ copies of +self+:;To:RDoc::Markup::Verbatim; [I"a = ['x', 'y'] ;TI"/a * 3 # => ["x", "y", "x", "y", "x", "y"] ;T: @format0o; ; [I"8When \String argument +string_separator+ is given, ;TI"9equivalent to array.join(string_separator):;To; ; [I";[0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {:foo=>0}";T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Carray * n -> new_array array * string_separator -> new_string ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]Ǜ{,, insert-i.rinu[U:RDoc::AnyMethod[iI" insert:ETI"Array#insert;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"UInserts given +objects+ before or after the element at \Integer index +offset+; ;TI"returns +self+.;To:RDoc::Markup::BlankLineo; ; [I"?When +index+ is non-negative, inserts all given +objects+ ;TI"*before the element at offset +index+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"?a.insert(1, :bat, :bam) # => [:foo, :bat, :bam, "bar", 2] ;T: @format0o; ; [I"TExtends the array if +index+ is beyond the array (index >= self.size):;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.insert(5, :bat, :bam) ;TI"3a # => [:foo, "bar", 2, nil, nil, :bat, :bam] ;T; 0o; ; [I"&Does nothing if no objects given:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"a.insert(1) ;TI"a.insert(50) ;TI"a.insert(-50) ;TI"a # => [:foo, "bar", 2] ;T; 0o; ; [I";When +index+ is negative, inserts all given +objects+ ;TI"<_after_ the element at offset index+self.size:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.insert(-2, :bat, :bam) ;TI"(a # => [:foo, "bar", :bat, :bam, 2];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"+array.insert(index, *objects) -> self ;T0[I" (*args);T@3FI" Array;TcRDoc::NormalClass00PK]UO flatten-i.rinu[U:RDoc::AnyMethod[iI" flatten:ETI"Array#flatten;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"CReturns a new \Array that is a recursive flattening of +self+:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I")Each non-Array element is unchanged.;To;;0; [o; ; [I"8Each \Array is replaced by its individual elements.;To:RDoc::Markup::BlankLineo; ; [I"^With non-negative \Integer argument +level+, flattens recursively through +level+ levels:;To:RDoc::Markup::Verbatim; [ I"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI".a.flatten(0) # => [0, [1, [2, 3], 4], 5] ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI",a.flatten(1) # => [0, 1, [2, 3], 4, 5] ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"*a.flatten(2) # => [0, 1, 2, 3, 4, 5] ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"*a.flatten(3) # => [0, 1, 2, 3, 4, 5] ;T: @format0o; ; [I"`With no argument, a +nil+ argument, or with negative argument +level+, flattens all levels:;To;; [ I"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"'a.flatten # => [0, 1, 2, 3, 4, 5] ;TI"&[0, 1, 2].flatten # => [0, 1, 2] ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"+a.flatten(-1) # => [0, 1, 2, 3, 4, 5] ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"+a.flatten(-2) # => [0, 1, 2, 3, 4, 5] ;TI")[0, 1, 2].flatten(-1) # => [0, 1, 2];T;0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Barray.flatten -> new_array array.flatten(level) -> new_array ;T0[I" (*args);T@5FI" Array;TcRDoc::NormalClass00PK] >|  include%3f-i.rinu[U:RDoc::AnyMethod[iI" include?:ETI"Array#include?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"NReturns +true+ if for some index +i+ in +self+, obj == self[i]; ;TI"otherwise +false+:;To:RDoc::Markup::Verbatim; [I"%[0, 1, 2].include?(2) # => true ;TI"%[0, 1, 2].include?(3) # => false;T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"*array.include?(obj) -> true or false ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]: push-i.rinu[U:RDoc::AnyMethod[iI" push:ETI"Array#push;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Appends trailing elements.;To:RDoc::Markup::BlankLineo; ; [I"CAppends each argument in +objects+ to +self+; returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI":a.push(:baz, :bat) # => [:foo, "bar", 2, :baz, :bat] ;T: @format0o; ; [I"HAppends each argument as one element, even if it is another \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"-a1 = a.push([:baz, :bat], [:bam, :bad]) ;TI":a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]] ;T; 0o; ; [I".Array#append is an alias for \Array#push.;T@o; ; [I"%Related: #pop, #shift, #unshift.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I""array.push(*objects) -> self ;T0[[I" append;T@ I" (*args);T@$FI" Array;TcRDoc::NormalClass00PK]: drop-i.rinu[U:RDoc::AnyMethod[iI" drop:ETI"Array#drop;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"NReturns a new \Array containing all but the first +n+ element of +self+, ;TI"+where +n+ is a non-negative \Integer; ;TI"does not modify +self+.;To:RDoc::Markup::BlankLineo; ; [I"Examples:;To:RDoc::Markup::Verbatim; [ I"a = [0, 1, 2, 3, 4, 5] ;TI"'a.drop(0) # => [0, 1, 2, 3, 4, 5] ;TI"$a.drop(1) # => [1, 2, 3, 4, 5] ;TI" a.drop(2) # => [2, 3, 4, 5];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I" array.drop(n) -> new_array ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]9[[ collect-i.rinu[U:RDoc::AnyMethod[iI" collect:ETI"Array#collect;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"=Calls the block, if given, with each element of +self+; ;TI"Nreturns a new \Array whose elements are the return values from the block:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"+a1 = a.map {|element| element.class } ;TI"'a1 # => [Symbol, String, Integer] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.map ;TI"1a1 # => # ;T; 0o; ; [I"-Array#collect is an alias for Array#map.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Iarray.map {|element| ... } -> new_array array.map -> new_enumerator ;T0[[I"map;T@ I"();T@FI" Array;TcRDoc::NormalClass00PK]2 concat-i.rinu[U:RDoc::AnyMethod[iI" concat:ETI"Array#concat;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"UAdds to +array+ all elements from each \Array in +other_arrays+; returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [0, 1] ;TI"5a.concat([2, 3], [4, 5]) # => [0, 1, 2, 3, 4, 5];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I")array.concat(*other_arrays) -> self ;T0[I" (*args);T@FI" Array;TcRDoc::NormalClass00PK]YD product-i.rinu[U:RDoc::AnyMethod[iI" product:ETI"Array#product;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"VComputes and returns or yields all combinations of elements from all the Arrays, ;TI".including both +self+ and +other_arrays+.;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"OThe number of combinations is the product of the sizes of all the arrays, ;TI".including both +self+ and +other_arrays+.;To;;0; [o; ; [I"=The order of the returned combinations is indeterminate.;To:RDoc::Markup::BlankLineo; ; [I"MWhen no block is given, returns the combinations as an \Array of Arrays:;To:RDoc::Markup::Verbatim; [I"a = [0, 1, 2] ;TI"a1 = [3, 4] ;TI"a2 = [5, 6] ;TI"p = a.product(a1) ;TI"&p.size # => 6 # a.size * a1.size ;TI"=p # => [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]] ;TI"p = a.product(a1, a2) ;TI"1p.size # => 12 # a.size * a1.size * a2.size ;TI"p # => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]] ;T: @format0o; ; [I"AIf any argument is an empty \Array, returns an empty \Array.;T@o; ; [I"EIf no argument is given, returns an \Array of 1-element Arrays, ;TI"*each containing an element of +self+:;To;; [I"$a.product # => [[0], [1], [2]] ;T;0o; ; [I"QWhen a block is given, yields each combination as an \Array; returns +self+:;To;; [I"2a.product(a1) {|combination| p combination } ;T;0o; ; [I" Output:;To;; [ I" [0, 3] ;TI" [0, 4] ;TI" [1, 3] ;TI" [1, 4] ;TI" [2, 3] ;TI" [2, 4] ;T;0o; ; [I"AIf any argument is an empty \Array, does not call the block:;To;; [I"Aa.product(a1, a2, []) {|combination| fail 'Cannot happen' } ;T;0o; ; [I"RIf no argument is given, yields each element of +self+ as a 1-element \Array:;To;; [I".a.product {|combination| p combination } ;T;0o; ; [I" Output:;To;; [I" [0] ;TI" [1] ;TI"[2];T;0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"iarray.product(*other_arrays) -> new_array array.product(*other_arrays) {|combination| ... } -> self ;T0[I" (*args);T@ZFI" Array;TcRDoc::NormalClass00PK]Deach_index-i.rinu[U:RDoc::AnyMethod[iI"each_index:ETI"Array#each_index;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"!Iterates over array indexes.;To:RDoc::Markup::BlankLineo; ; [I"JWhen a block given, passes each successive array index to the block; ;TI"returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI":a.each_index {|index| puts "#{index} #{a[index]}" } ;T: @format0o; ; [I" Output:;To; ; [I" 0 foo ;TI" 1 bar ;TI" 2 2 ;T; 0o; ; [I"6Allows the array to be modified during iteration:;To; ; [I"a = [:foo, 'bar', 2] ;TI">a.each_index {|index| puts index; a.clear if index > 0 } ;T; 0o; ; [I" Output:;To; ; [I"0 ;TI"1 ;T; 0o; ; [I"4When no block given, returns a new \Enumerator:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"e = a.each_index ;TI"7e # => # ;TI"8a1 = e.each {|index| puts "#{index} #{a[index]}"} ;T; 0o; ; [I" Output:;To; ; [I" 0 foo ;TI" 1 bar ;TI" 2 2 ;T; 0o; ; [I"#Related: #each, #reverse_each.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Larray.each_index {|index| ... } -> self array.each_index -> Enumerator ;T0[I"();T@AFI" Array;TcRDoc::NormalClass00PK]T'"ll unshift-i.rinu[U:RDoc::AnyMethod[iI" unshift:ETI"Array#unshift;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I",Prepends the given +objects+ to +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"=a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2] ;T: @format0o; ; [I"1Array#prepend is an alias for Array#unshift.;To:RDoc::Markup::BlankLineo; ; [I""Related: #push, #pop, #shift.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"%array.unshift(*objects) -> self ;T0[[I" prepend;T@ I" (*args);T@FI" Array;TcRDoc::NormalClass00PK]reverse%21-i.rinu[U:RDoc::AnyMethod[iI" reverse!:ETI"Array#reverse!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Reverses +self+ in place:;To:RDoc::Markup::Verbatim; [I"a = ['foo', 'bar', 'two'] ;TI"*a.reverse! # => ["two", "bar", "foo"];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array.reverse! -> self ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]Fx slice%21-i.rinu[U:RDoc::AnyMethod[iI" slice!:ETI"Array#slice!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I".Removes and returns elements from +self+.;To:RDoc::Markup::BlankLineo; ; [I"0When the only argument is an \Integer +n+, ;TI"5removes and returns the _nth_ element in +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.slice!(1) # => "bar" ;TI"a # => [:foo, 2] ;T: @format0o; ; [I"AIf +n+ is negative, counts backwards from the end of +self+:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.slice!(-1) # => 2 ;TI"a # => [:foo, "bar"] ;T; 0o; ; [I"+If +n+ is out of range, returns +nil+.;T@o; ; [I"@When the only arguments are Integers +start+ and +length+, ;TI"Iremoves +length+ elements from +self+ beginning at offset +start+; ;TI"0returns the deleted objects in a new Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"'a.slice!(0, 2) # => [:foo, "bar"] ;TI"a # => [2] ;T; 0o; ; [I"8If start + length exceeds the array size, ;TI"Eremoves and returns all elements from offset +start+ to the end:;To; ; [I"a = [:foo, 'bar', 2] ;TI"%a.slice!(1, 50) # => ["bar", 2] ;TI"a # => [:foo] ;T; 0o; ; [I"?If start == a.size and +length+ is non-negative, ;TI" returns a new empty \Array.;T@o; ; [I",If +length+ is negative, returns +nil+.;T@o; ; [I"8When the only argument is a \Range object +range+, ;TI"Ztreats range.min as +start+ above and range.size as +length+ above:;To; ; [I"a = [:foo, 'bar', 2] ;TI"% a.slice!(1..2) # => ["bar", 2] ;TI"a # => [:foo] ;T; 0o; ; [I"CIf range.start == a.size, returns a new empty \Array.;T@o; ; [I"JIf range.start is larger than the array size, returns +nil+.;T@o; ; [I"SIf range.end is negative, counts backwards from the end of the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"(a.slice!(0..-2) # => [:foo, "bar"] ;TI"a # => [2] ;T; 0o; ; [I"*If range.start is negative, ;TI"Dcalculates the start index backwards from the end of the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"%a.slice!(-2..2) # => ["bar", 2] ;TI"a # => [:foo];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"~array.slice!(n) -> object or nil array.slice!(start, length) -> new_array or nil array.slice!(range) -> new_array or nil ;T0[I" (*args);T@]FI" Array;TcRDoc::NormalClass00PK]֍=ffreverse_each-i.rinu[U:RDoc::AnyMethod[iI"reverse_each:ETI"Array#reverse_each;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I",Iterates backwards over array elements.;To:RDoc::Markup::BlankLineo; ; [I"NWhen a block given, passes, in reverse order, each element to the block; ;TI"returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"Ea.reverse_each {|element| puts "#{element.class} #{element}" } ;T: @format0o; ; [I" Output:;To; ; [I"Integer 2 ;TI"String bar ;TI"Symbol foo ;T; 0o; ; [I"6Allows the array to be modified during iteration:;To; ; [I"a = [:foo, 'bar', 2] ;TI"Xa.reverse_each {|element| puts element; a.clear if element.to_s.start_with?('b') } ;T; 0o; ; [I" Output:;To; ; [I"2 ;TI" bar ;T; 0o; ; [I"4When no block given, returns a new \Enumerator:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"e = a.reverse_each ;TI"9e # => # ;TI"Ba1 = e.each {|element| puts "#{element.class} #{element}" } ;T; 0o; ; [I" Output:;To; ; [I"Integer 2 ;TI"String bar ;TI"Symbol foo ;T; 0o; ; [I"!Related: #each, #each_index.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Rarray.reverse_each {|element| ... } -> self array.reverse_each -> Enumerator ;T0[I"();T@AFI" Array;TcRDoc::NormalClass00PK]y1Feecollect%21-i.rinu[U:RDoc::AnyMethod[iI" collect!:ETI"Array#collect!;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"3Calls the block, if given, with each element; ;TI"8replaces the element with the block's return value:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"Ga.map! { |element| element.class } # => [Symbol, String, Integer] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.map! ;TI"2a1 # => # ;T; 0o; ; [I"/Array#collect! is an alias for Array#map!.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Farray.map! {|element| ... } -> self array.map! -> new_enumerator ;T0[[I" map!;T@ [I" map!;To;; [; I"lib/racc/compat.rb;T;0I"();T@FI" Array;TcRDoc::NormalClass00PK]qNfilter%21-i.rinu[U:RDoc::AnyMethod[iI" filter!:ETI"Array#filter!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"=Calls the block, if given with each element of +self+; ;TI"Uremoves from +self+ those elements for which the block returns +false+ or +nil+.;To:RDoc::Markup::BlankLineo; ; [I"1Returns +self+ if any elements were removed:;To:RDoc::Markup::Verbatim; [I" a = [:foo, 'bar', 2, :bam] ;TI"Ma.select! {|element| element.to_s.start_with?('b') } # => ["bar", :bam] ;T: @format0o; ; [I"/Returns +nil+ if no elements were removed.;T@o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I" a = [:foo, 'bar', 2, :bam] ;TI"Ba.select! # => # ;T; 0o; ; [I"1Array#filter! is an alias for Array#select!.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@$FI" Array;TcRDoc::NormalClass0[@'FI" select!;TPK]l4intersection-i.rinu[U:RDoc::AnyMethod[iI"intersection:ETI"Array#intersection;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"GReturns a new \Array containing each element found both in +self+ ;TI"4and in all of the given Arrays +other_arrays+; ;TI"Dduplicates are omitted; items are compared using eql?:;To:RDoc::Markup::Verbatim; [I"A[0, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1] ;TI"G[0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1] ;T: @format0o; ; [I"!Preserves order from +self+:;To; ; [I"6[0, 1, 2].intersection([2, 1, 0]) # => [0, 1, 2] ;T; 0o; ; [I"4Returns a copy of +self+ if no arguments given.;To:RDoc::Markup::BlankLineo; ; [I"Related: Array#&.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"4array.intersection(*other_arrays) -> new_array ;T0[I" (*args);T@!FI" Array;TcRDoc::NormalClass00PK]#   one%3f-i.rinu[U:RDoc::AnyMethod[iI" one?:ETI"Array#one?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"MReturns +true+ if exactly one element of +self+ meets a given criterion.;To:RDoc::Markup::BlankLineo; ; [I"cWith no block given and no argument, returns +true+ if +self+ has exactly one truthy element, ;TI"+false+ otherwise:;To:RDoc::Markup::Verbatim; [ I"[nil, 0].one? # => true ;TI"[0, 0].one? # => false ;TI" [nil, nil].one? # => false ;TI"[].one? # => false ;T: @format0o; ; [I"VWith a block given and no argument, calls the block with each element in +self+; ;TI"[returns +true+ if the block a truthy value for exactly one element, +false+ otherwise:;To; ; [I"8[0, 1, 2].one? {|element| element > 0 } # => false ;TI"7[0, 1, 2].one? {|element| element > 1 } # => true ;TI"8[0, 1, 2].one? {|element| element > 2 } # => false ;T; 0o; ; [I"YIf argument +obj+ is given, returns +true+ if obj.=== exactly one element, ;TI"+false+ otherwise:;To; ; [ I"![0, 1, 2].one?(0) # => true ;TI""[0, 0, 1].one?(0) # => false ;TI""[1, 1, 2].one?(0) # => false ;TI".['food', 'drink'].one?(/bar/) # => false ;TI"-['food', 'drink'].one?(/foo/) # => true ;TI"[].one?(/foo/) # => false ;T; 0o; ; [I"Related: Enumerable#one?;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"oarray.one? -> true or false array.one? {|element| ... } -> true or false array.one?(obj) -> true or false ;T0[I" (*args);T@1FI" Array;TcRDoc::NormalClass00PK]v  max-i.rinu[U:RDoc::AnyMethod[iI"max:ETI"Array#max;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I""Returns one of the following:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I",The maximum-valued element from +self+.;To;;0; [o; ; [I"BA new \Array of maximum-valued elements selected from +self+.;To:RDoc::Markup::BlankLineo; ; [I"XWhen no block is given, each element in +self+ must respond to method <=> ;TI"with an \Integer.;T@o; ; [I"BWith no argument and no block, returns the element in +self+ ;TI"6having the maximum value per method <=>:;To:RDoc::Markup::Verbatim; [I"[0, 1, 2].max # => 2 ;T: @format0o; ; [I"aWith an argument \Integer +n+ and no block, returns a new \Array with at most +n+ elements, ;TI"1in descending order per method <=>:;To;; [I"([0, 1, 2, 3].max(3) # => [3, 2, 1] ;TI"+[0, 1, 2, 3].max(6) # => [3, 2, 1, 0] ;T;0o; ; [I">When a block is given, the block must return an \Integer.;T@o; ; [I"cWith a block and no argument, calls the block self.size-1 times to compare elements; ;TI"@returns the element having the maximum value per the block:;To;; [I"C['0', '00', '000'].max {|a, b| a.size <=> b.size } # => "000" ;T;0o; ; [I"WWith an argument +n+ and a block, returns a new \Array with at most +n+ elements, ;TI"'in descending order per the block:;To;; [I"M['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"];T;0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array.max -> element array.max {|a, b| ... } -> element array.max(n) -> new_array array.max(n) {|a, b| ... } -> new_array ;T0[I" (*args);T@?FI" Array;TcRDoc::NormalClass00PK].ܑ bsearch-i.rinu[U:RDoc::AnyMethod[iI" bsearch:ETI"Array#bsearch;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"@Returns an element from +self+ selected by a binary search.;To:RDoc::Markup::BlankLineo; ; [I"3See {Binary Searching}[rdoc-ref:bsearch.rdoc].;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Narray.bsearch {|element| ... } -> object array.bsearch -> new_enumerator ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]; join-i.rinu[U:RDoc::AnyMethod[iI" join:ETI"Array#join;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"TReturns the new \String formed by joining the array elements after conversion. ;TI"For each element +element+;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"OUses element.to_s if +element+ is not a kind_of?(Array).;To;;0; [o; ; [I"`Uses recursive element.join(separator) if +element+ is a kind_of?(Array).;To:RDoc::Markup::BlankLineo; ; [I"KWith no argument, joins using the output field separator, $,:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"$, # => nil ;TI"a.join # => "foobar2" ;T: @format0o; ; [I"CWith \string argument +separator+, joins using that separator:;To;; [I"a = [:foo, 'bar', 2] ;TI"%a.join("\n") # => "foo\nbar\n2" ;T;0o; ; [I")Joins recursively for nested Arrays:;To;; [I"&a = [:foo, [:bar, [:baz, :bat]]] ;TI"a.join # => "foobarbazbat";T;0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Farray.join ->new_string array.join(separator = $,) -> new_string ;T0[I" (*args);T@2FI" Array;TcRDoc::NormalClass00PK]g 66 size-i.rinu[U:RDoc::AnyMethod[iI" size:ETI"Array#size;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"-Returns the count of elements in +self+.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Array;TcRDoc::NormalClass0[@FI" length;TPK]꜖ select-i.rinu[U:RDoc::AnyMethod[iI" select:ETI"Array#select;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"=Calls the block, if given, with each element of +self+; ;TI">returns a new \Array containing those elements of +self+ ;TI"0for which the block returns a truthy value:;To:RDoc::Markup::Verbatim; [I" a = [:foo, 'bar', 2, :bam] ;TI">a1 = a.select {|element| element.to_s.start_with?('b') } ;TI"a1 # => ["bar", :bam] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I" a = [:foo, 'bar', 2, :bam] ;TI"@a.select # => # ;T; 0o; ; [I"/Array#filter is an alias for Array#select.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Oarray.select {|element| ... } -> new_array array.select -> new_enumerator ;T0[[I" filter;T@ I"();T@FI" Array;TcRDoc::NormalClass00PK]IGKKsum-i.rinu[U:RDoc::AnyMethod[iI"sum:ETI"Array#sum;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I">When no block is given, returns the object equivalent to:;To:RDoc::Markup::Verbatim; [I"sum = init ;TI",array.each {|element| sum += element } ;TI" sum ;T: @format0o; ; [I"QFor example, [e1, e2, e3].sum returns init + e1 + e2 + e3.;To:RDoc::Markup::BlankLineo; ; [I"Examples:;To; ; [I"a = [0, 1, 2, 3] ;TI"a.sum # => 6 ;TI"a.sum(100) # => 106 ;T; 0o; ; [I"IThe elements need not be numeric, but must be +-compatible ;TI"%with each other and with +init+:;To; ; [I"a = ['abc', 'def', 'ghi'] ;TI"&a.sum('jkl') # => "jklabcdefghi" ;T; 0o; ; [I";When a block is given, it is called with each element ;TI"Xand the block's return value (instead of the element itself) is used as the addend:;To; ; [I"a = ['zero', 1, :two] ;TI"Gs = a.sum('Coerced and concatenated: ') {|element| element.to_s } ;TI"1s # => "Coerced and concatenated: zero1two" ;T; 0o; ; [I" Notes:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"?Array#join and Array#flatten may be faster than Array#sum ;TI"5for an \Array of Strings or an \Array of Arrays.;To;;0; [o; ; [I"[Array#sum method may not respect method redefinition of "+" methods such as Integer#+.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Rarray.sum(init = 0) -> object array.sum(init = 0) {|element| ... } -> object ;T0[I" (*args);T@@FI" Array;TcRDoc::NormalClass00PK]7--repeated_combination-i.rinu[U:RDoc::AnyMethod[iI"repeated_combination:ETI"Array#repeated_combination;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"]Calls the block with each repeated combination of length +n+ of the elements of +self+; ;TI"$each combination is an \Array; ;TI"Dreturns +self+. The order of the combinations is indeterminate.;To:RDoc::Markup::BlankLineo; ; [I"\When a block and a positive \Integer argument +n+ are given, calls the block with each ;TI"?+n+-tuple repeated combination of the elements of +self+. ;TI"9The number of combinations is (n+1)(n+2)/2.;T@o; ; [I" +n+ = 1:;To:RDoc::Markup::Verbatim; [I"a = [0, 1, 2] ;TI">a.repeated_combination(1) {|combination| p combination } ;T: @format0o; ; [I" Output:;To; ; [I" [0] ;TI" [1] ;TI" [2] ;T; 0o; ; [I" +n+ = 2:;To; ; [I">a.repeated_combination(2) {|combination| p combination } ;T; 0o; ; [I" Output:;To; ; [ I" [0, 0] ;TI" [0, 1] ;TI" [0, 2] ;TI" [1, 1] ;TI" [1, 2] ;TI" [2, 2] ;T; 0o; ; [I"?If +n+ is zero, calls the block once with an empty \Array.;T@o; ; [I"1If +n+ is negative, does not call the block:;To; ; [I"Fa.repeated_combination(-1) {|combination| fail 'Cannot happen' } ;T; 0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [0, 1, 2] ;TI"La.repeated_combination(2) # => # ;T; 0o; ; [I"LUsing Enumerators, it's convenient to show the combinations and counts ;TI"for some values of +n+:;To; ; [I"#e = a.repeated_combination(0) ;TI"e.size # => 1 ;TI"e.to_a # => [[]] ;TI"#e = a.repeated_combination(1) ;TI"e.size # => 3 ;TI"!e.to_a # => [[0], [1], [2]] ;TI"#e = a.repeated_combination(2) ;TI"e.size # => 6 ;TI"Ae.to_a # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"parray.repeated_combination(n) {|combination| ... } -> self array.repeated_combination(n) -> new_enumerator ;T0[I" (p1);T@UFI" Array;TcRDoc::NormalClass00PK]9\ %5b%5d-i.rinu[U:RDoc::AnyMethod[iI"[]:ETI" Array#[];TF: privateo:RDoc::Markup::Document: @parts[&o:RDoc::Markup::Paragraph; [I":Returns elements from +self+; does not modify +self+.;To:RDoc::Markup::BlankLineo; ; [I"]When a single \Integer argument +index+ is given, returns the element at offset +index+:;To:RDoc::Markup::Verbatim; [ I"a = [:foo, 'bar', 2] ;TI"a[0] # => :foo ;TI"a[2] # => 2 ;TI"a # => [:foo, "bar", 2] ;T: @format0o; ; [I"BIf +index+ is negative, counts relative to the end of +self+:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a[-1] # => 2 ;TI"a[-2] # => "bar" ;T; 0o; ; [I"/If +index+ is out of range, returns +nil+.;T@o; ; [I"AWhen two \Integer arguments +start+ and +length+ are given, ;TI"freturns a new \Array of size +length+ containing successive elements beginning at offset +start+:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[0, 2] # => [:foo, "bar"] ;TI"a[1, 2] # => ["bar", 2] ;T; 0o; ; [I"FIf start + length is greater than self.length, ;TI"9returns all elements from offset +start+ to the end:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"#a[0, 4] # => [:foo, "bar", 2] ;TI"a[1, 3] # => ["bar", 2] ;TI"a[2, 2] # => [2] ;T; 0o; ; [I">If start == self.size and length >= 0, ;TI" returns a new empty \Array.;T@o; ; [I",If +length+ is negative, returns +nil+.;T@o; ; [I"5When a single \Range argument +range+ is given, ;TI"0treats range.min as +start+ above ;TI"/and range.size as +length+ above:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[0..1] # => [:foo, "bar"] ;TI"a[1..2] # => ["bar", 2] ;T; 0o; ; [I"QSpecial case: If range.start == a.size, returns a new empty \Array.;T@o; ; [I"NIf range.end is negative, calculates the end index from the end:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"$a[0..-1] # => [:foo, "bar", 2] ;TI"!a[0..-2] # => [:foo, "bar"] ;TI"a[0..-3] # => [:foo] ;T; 0o; ; [I"RIf range.start is negative, calculates the start index from the end:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"a[-1..2] # => [2] ;TI"a[-2..2] # => ["bar", 2] ;TI"$a[-3..2] # => [:foo, "bar", 2] ;T; 0o; ; [I"JIf range.start is larger than the array size, returns +nil+.;To; ; [ I"a = [:foo, 'bar', 2] ;TI"a[4..1] # => nil ;TI"a[4..0] # => nil ;TI"a[4..-1] # => nil ;T; 0o; ; [I"LWhen a single Enumerator::ArithmeticSequence argument +aseq+ is given, ;TI"Kreturns an Array of elements corresponding to the indexes produced by ;TI"the sequence.;To; ; [I"7a = ['--', 'data1', '--', 'data2', '--', 'data3'] ;TI"7a[(1..).step(2)] # => ["data1", "data2", "data3"] ;T; 0o; ; [I"SUnlike slicing with range, if the start or the end of the arithmetic sequence ;TI"2is larger than array size, throws RangeError.;To; ; [ I"7a = ['--', 'data1', '--', 'data2', '--', 'data3'] ;TI"a[(1..11).step(2)] ;TI"3# RangeError (((1..11).step(2)) out of range) ;TI"a[(7..).step(2)] ;TI"1# RangeError (((7..).step(2)) out of range) ;T; 0o; ; [I"QIf given a single argument, and its type is not one of the listed, tries to ;TI";convert it to Integer, and raises if it is impossible:;To; ; [I"a = [:foo, 'bar', 2] ;TI"I# Raises TypeError (no implicit conversion of Symbol into Integer): ;TI" a[:foo] ;T; 0o; ; [I"*Array#slice is an alias for Array#[].;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array[index] -> object or nil array[start, length] -> object or nil array[range] -> object or nil array[aseq] -> object or nil array.slice(index) -> object or nil array.slice(start, length) -> object or nil array.slice(range) -> object or nil array.slice(aseq) -> object or nil ;T0[[I" slice;T@ I" (*args);T@FI" Array;TcRDoc::NormalClass00PK]Gv>at-i.rinu[U:RDoc::AnyMethod[iI"at:ETI" Array#at;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LReturns the element at \Integer offset +index+; does not modify +self+.;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.at(0) # => :foo ;TI"a.at(2) # => 2;T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array.at(index) -> object ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]Bۈ count-i.rinu[U:RDoc::AnyMethod[iI" count:ETI"Array#count;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"+Returns a count of specified elements.;To:RDoc::Markup::BlankLineo; ; [I"FWith no argument and no block, returns the count of all elements:;To:RDoc::Markup::Verbatim; [I"[0, 1, 2].count # => 3 ;TI"[].count # => 0 ;T: @format0o; ; [I"MWith argument +obj+, returns the count of elements == to +obj+:;To; ; [I"$[0, 1, 2, 0.0].count(0) # => 2 ;TI"[0, 1, 2].count(3) # => 0 ;T; 0o; ; [I"LWith no argument and a block given, calls the block with each element; ;TI"Nreturns the count of elements for which the block returns a truthy value:;To; ; [I"7[0, 1, 2, 3].count {|element| element > 1} # => 2 ;T; 0o; ; [I"QWith argument +obj+ and a block given, issues a warning, ignores the block, ;TI"== to +obj+:;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"iarray.count -> an_integer array.count(obj) -> an_integer array.count {|element| ... } -> an_integer ;T0[I" (*args);T@(FI" Array;TcRDoc::NormalClass00PK]F to_s-i.rinu[U:RDoc::AnyMethod[iI" to_s:ETI"Array#to_s;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"HReturns the new \String formed by calling method #inspect ;TI"on each array element:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI")a.inspect # => "[:foo, \"bar\", 2]" ;T: @format0o; ; [I".Array#to_s is an alias for Array#inspect.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Array;TcRDoc::NormalClass0[@FI" inspect;TPK]!yy delete-i.rinu[U:RDoc::AnyMethod[iI" delete:ETI"Array#delete;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"?Removes zero or more elements from +self+; returns +self+.;To:RDoc::Markup::BlankLineo; ; [I"When no block is given, ;TI"Kremoves from +self+ each element +ele+ such that ele == obj; ;TI"&returns the last deleted element:;To:RDoc::Markup::Verbatim; [ I"s1 = 'bar'; s2 = 'bar' ;TI"a = [:foo, s1, 2, s2] ;TI" a.delete('bar') # => "bar" ;TI"a # => [:foo, 2] ;T: @format0o; ; [I"*Returns +nil+ if no elements removed.;T@o; ; [I"When a block is given, ;TI"Jremoves from +self+ each element +ele+ such that ele == obj.;T@o; ; [I"7If any such elements are found, ignores the block ;TI"*and returns the last deleted element:;To; ; [ I"s1 = 'bar'; s2 = 'bar' ;TI"a = [:foo, s1, 2, s2] ;TI"Adeleted_obj = a.delete('bar') {|obj| fail 'Cannot happen' } ;TI"a # => [:foo, 2] ;T; 0o; ; [I"EIf no such elements are found, returns the block's return value:;To; ; [I"a = [:foo, 'bar', 2] ;TI"Ja.delete(:nosuch) {|obj| "#{obj} not found" } # => "nosuch not found";T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"marray.delete(obj) -> deleted_object array.delete(obj) {|nosuch| ... } -> deleted_object or block_return ;T0[I" (p1);T@2FI" Array;TcRDoc::NormalClass00PK]y9oo index-i.rinu[U:RDoc::AnyMethod[iI" index:ETI"Array#index;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I".Returns the index of a specified element.;To:RDoc::Markup::BlankLineo; ; [I"3When argument +object+ is given but no block, ;TI"6returns the index of the first element +element+ ;TI"*for which object == element:;To:RDoc::Markup::Verbatim; [I"!a = [:foo, 'bar', 2, 'bar'] ;TI"a.index('bar') # => 1 ;T: @format0o; ; [I",Returns +nil+ if no such element found.;T@o; ; [I"8When both argument +object+ and a block are given, ;TI"3calls the block with each successive element; ;TI"Wreturns the index of the first element for which the block returns a truthy value:;To; ; [I"!a = [:foo, 'bar', 2, 'bar'] ;TI"2a.index {|element| element == 'bar' } # => 1 ;T; 0o; ; [I"=Returns +nil+ if the block never returns a truthy value.;T@o; ; [I"MWhen neither an argument nor a block is given, returns a new Enumerator:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"e = a.index ;TI"2e # => # ;TI"1e.each {|element| element == 'bar' } # => 1 ;T; 0o; ; [I"2Array#find_index is an alias for Array#index.;T@o; ; [I"Related: #rindex.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@6FI" Array;TcRDoc::NormalClass0[@9FI"find_index;TPK]"b1xx all%3f-i.rinu[U:RDoc::AnyMethod[iI" all?:ETI"Array#all?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"EReturns +true+ if all elements of +self+ meet a given criterion.;To:RDoc::Markup::BlankLineo; ; [I"bWith no block given and no argument, returns +true+ if +self+ contains only truthy elements, ;TI"+false+ otherwise:;To:RDoc::Markup::Verbatim; [I"![0, 1, :foo].all? # => true ;TI"![0, nil, 2].all? # => false ;TI"[].all? # => true ;T: @format0o; ; [I"VWith a block given and no argument, calls the block with each element in +self+; ;TI"Oreturns +true+ if the block returns only truthy values, +false+ otherwise:;To; ; [I"8[0, 1, 2].all? { |element| element < 3 } # => true ;TI"9[0, 1, 2].all? { |element| element < 2 } # => false ;T; 0o; ; [I"eIf argument +obj+ is given, returns +true+ if obj.=== every element, +false+ otherwise:;To; ; [ I"4['food', 'fool', 'foot'].all?(/foo/) # => true ;TI".['food', 'drink'].all?(/bar/) # => false ;TI"[].all?(/foo/) # => true ;TI"![0, 0, 0].all?(0) # => true ;TI""[0, 1, 2].all?(1) # => false ;T; 0o; ; [I"Related: Enumerable#all?;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"oarray.all? -> true or false array.all? {|element| ... } -> true or false array.all?(obj) -> true or false ;T0[I" (*args);T@-FI" Array;TcRDoc::NormalClass00PK]l||intersect%3f-i.rinu[U:RDoc::AnyMethod[iI"intersect?:ETI"Array#intersect?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"NReturns +true+ if the array and +other_ary+ have at least one element in ;TI"'common, otherwise returns +false+.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"a = [ 1, 2, 3 ] ;TI"b = [ 3, 4, 5 ] ;TI"c = [ 5, 6, 7 ] ;TI" a.intersect?(b) #=> true ;TI" a.intersect?(c) #=> false;T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"2ary.intersect?(other_ary) -> true or false ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]|h   uniq-i.rinu[U:RDoc::AnyMethod[iI" uniq:ETI"Array#uniq;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"YReturns a new \Array containing those elements from +self+ that are not duplicates, ;TI"0the first occurrence always being retained.;To:RDoc::Markup::BlankLineo; ; [I"UWith no block given, identifies and omits duplicates using method eql? ;TI"to compare.;To:RDoc::Markup::Verbatim; [I"a = [0, 0, 1, 1, 2, 2] ;TI"a.uniq # => [0, 1, 2] ;T: @format0o; ; [I";With a block given, calls the block for each element; ;TI"Iidentifies (using method eql?) and omits duplicate values, ;TI"Hthat is, those elements for which the block returns the same value:;To; ; [I".a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] ;TI"=a.uniq {|element| element.size } # => ["a", "aa", "aaa"];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Farray.uniq -> new_array array.uniq {|element| ... } -> new_array ;T0[I"();T@!FI" Array;TcRDoc::NormalClass00PK]N min-i.rinu[U:RDoc::AnyMethod[iI"min:ETI"Array#min;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I""Returns one of the following:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I",The minimum-valued element from +self+.;To;;0; [o; ; [I"BA new \Array of minimum-valued elements selected from +self+.;To:RDoc::Markup::BlankLineo; ; [I"XWhen no block is given, each element in +self+ must respond to method <=> ;TI"with an \Integer.;T@o; ; [I"BWith no argument and no block, returns the element in +self+ ;TI"6having the minimum value per method <=>:;To:RDoc::Markup::Verbatim; [I"[0, 1, 2].min # => 0 ;T: @format0o; ; [I"^With \Integer argument +n+ and no block, returns a new \Array with at most +n+ elements, ;TI"0in ascending order per method <=>:;To;; [I"([0, 1, 2, 3].min(3) # => [0, 1, 2] ;TI"+[0, 1, 2, 3].min(6) # => [0, 1, 2, 3] ;T;0o; ; [I"=When a block is given, the block must return an Integer.;T@o; ; [I"cWith a block and no argument, calls the block self.size-1 times to compare elements; ;TI"@returns the element having the minimum value per the block:;To;; [I"B['0', '00', '000'].min { |a, b| a.size <=> b.size } # => "0" ;T;0o; ; [I"WWith an argument +n+ and a block, returns a new \Array with at most +n+ elements, ;TI"&in ascending order per the block:;To;; [I"K['0', '00', '000'].min(2) {|a, b| a.size <=> b.size } # => ["0", "00"];T;0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"|array.min -> element array.min { |a, b| ... } -> element array.min(n) -> new_array array.min(n) { |a, b| ... } -> new_array ;T0[I" (*args);T@?FI" Array;TcRDoc::NormalClass00PK]R+g  shelljoin-i.rinu[U:RDoc::AnyMethod[iI"shelljoin:ETI"Array#shelljoin;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"HBuilds a command line string from an argument list +array+ joining ;TI"Hall elements escaped for the Bourne shell and separated by a space.;To:RDoc::Markup::BlankLineo; ; [I"*See Shellwords.shelljoin for details.;T: @fileI"lib/shellwords.rb;T:0@omit_headings_from_table_of_contents_below0I"array.shelljoin => string ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]Vfind_index-i.rinu[U:RDoc::AnyMethod[iI"find_index:ETI"Array#find_index;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I".Returns the index of a specified element.;To:RDoc::Markup::BlankLineo; ; [I"3When argument +object+ is given but no block, ;TI"6returns the index of the first element +element+ ;TI"*for which object == element:;To:RDoc::Markup::Verbatim; [I"!a = [:foo, 'bar', 2, 'bar'] ;TI"a.index('bar') # => 1 ;T: @format0o; ; [I",Returns +nil+ if no such element found.;T@o; ; [I"8When both argument +object+ and a block are given, ;TI"3calls the block with each successive element; ;TI"Wreturns the index of the first element for which the block returns a truthy value:;To; ; [I"!a = [:foo, 'bar', 2, 'bar'] ;TI"2a.index {|element| element == 'bar' } # => 1 ;T; 0o; ; [I"=Returns +nil+ if the block never returns a truthy value.;T@o; ; [I"MWhen neither an argument nor a block is given, returns a new Enumerator:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"e = a.index ;TI"2e # => # ;TI"1e.each {|element| element == 'bar' } # => 1 ;T; 0o; ; [I"2Array#find_index is an alias for Array#index.;T@o; ; [I"Related: #rindex.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"xarray.index(object) -> integer or nil array.index {|element| ... } -> integer or nil array.index -> new_enumerator ;T0[[I" index;T@ I" (*args);T@6FI" Array;TcRDoc::NormalClass00PK]`hh last-i.rinu[U:RDoc::AnyMethod[iI" last:ETI"Array#last;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I":Returns elements from +self+; +self+ is not modified.;To:RDoc::Markup::BlankLineo; ; [I"9When no argument is given, returns the last element:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.last # => 2 ;TI"a # => [:foo, "bar", 2] ;T: @format0o; ; [I"'If +self+ is empty, returns +nil+.;T@o; ; [I"8When non-negative \Innteger argument +n+ is given, ;TI"3returns the last +n+ elements in a new \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.last(2) # => ["bar", 2] ;T; 0o; ; [I"7If n >= array.size, returns all elements:;To; ; [I"a = [:foo, 'bar', 2] ;TI"&a.last(50) # => [:foo, "bar", 2] ;T; 0o; ; [I"5If n == 0, returns an new empty \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a.last(0) # [] ;T; 0o; ; [I"Related: #first.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"=array.last -> object or nil array.last(n) -> new_array ;T0[I" (*args);T@3FI" Array;TcRDoc::NormalClass00PK])Mdrop_while-i.rinu[U:RDoc::AnyMethod[iI"drop_while:ETI"Array#drop_while;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"OReturns a new \Array containing zero or more trailing elements of +self+; ;TI"does not modify +self+.;To:RDoc::Markup::BlankLineo; ; [I"QWith a block given, calls the block with each successive element of +self+; ;TI"2stops if the block returns +false+ or +nil+; ;TI"_returns a new Array _omitting_ those elements for which the block returned a truthy value:;To:RDoc::Markup::Verbatim; [I"a = [0, 1, 2, 3, 4, 5] ;TI":a.drop_while {|element| element < 3 } # => [3, 4, 5] ;T: @format0o; ; [I"4With no block given, returns a new \Enumerator:;To; ; [I"A[0, 1].drop_while # => # => #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Warray.drop_while {|element| ... } -> new_array array.drop_while -> new_enumerator ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]2delete_if-i.rinu[U:RDoc::AnyMethod[iI"delete_if:ETI"Array#delete_if;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"PRemoves each element in +self+ for which the block returns a truthy value; ;TI"returns +self+:;To:RDoc::Markup::Verbatim; [I"!a = [:foo, 'bar', 2, 'bat'] ;TI"Ka.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [:foo, 'bar', 2] ;TI"?a.delete_if # => #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Larray.delete_if {|element| ... } -> self array.delete_if -> Enumerator ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]== sort%21-i.rinu[U:RDoc::AnyMethod[iI" sort!:ETI"Array#sort!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"6Returns +self+ with its elements sorted in place.;To:RDoc::Markup::BlankLineo; ; [I"BWith no block, compares elements using operator <=> ;TI"(see Comparable):;To:RDoc::Markup::Verbatim; [ I"#a = 'abcde'.split('').shuffle ;TI"&a # => ["e", "b", "d", "a", "c"] ;TI" a.sort! ;TI"&a # => ["a", "b", "c", "d", "e"] ;T: @format0o; ; [I";With a block, calls the block with each element pair; ;TI"Kfor each element pair +a+ and +b+, the block should return an integer:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"(Negative when +b+ is to follow +a+.;To;;0; [o; ; [I"*Zero when +a+ and +b+ are equivalent.;To;;0; [o; ; [I"(Positive when +a+ is to follow +b+.;T@o; ; [I" Example:;To; ; [ I"#a = 'abcde'.split('').shuffle ;TI"&a # => ["e", "b", "d", "a", "c"] ;TI"a.sort! {|a, b| a <=> b } ;TI"&a # => ["a", "b", "c", "d", "e"] ;TI"a.sort! {|a, b| b <=> a } ;TI"&a # => ["e", "d", "c", "b", "a"] ;T; 0o; ; [I"NWhen the block returns zero, the order for +a+ and +b+ is indeterminate, ;TI"and may be unstable:;To; ; [ I"#a = 'abcde'.split('').shuffle ;TI"&a # => ["e", "b", "d", "a", "c"] ;TI"a.sort! {|a, b| 0 } ;TI"%a # => ["d", "e", "c", "a", "b"];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I";array.sort! -> self array.sort! {|a, b| ... } -> self ;T0[I"();T@CFI" Array;TcRDoc::NormalClass00PK] ,h rassoc-i.rinu[U:RDoc::AnyMethod[iI" rassoc:ETI"Array#rassoc;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I";Returns the first element in +self+ that is an \Array ;TI",whose second element == +obj+:;To:RDoc::Markup::Verbatim; [I"/a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] ;TI"a.rassoc(4) # => [2, 4] ;T: @format0o; ; [I"/Returns +nil+ if no such element is found.;To:RDoc::Markup::BlankLineo; ; [I"Related: #assoc.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"-array.rassoc(obj) -> found_array or nil ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]I FF prepend-i.rinu[U:RDoc::AnyMethod[iI" prepend:ETI"Array#prepend;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I",Prepends the given +objects+ to +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"=a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2] ;T: @format0o; ; [I"1Array#prepend is an alias for Array#unshift.;To:RDoc::Markup::BlankLineo; ; [I""Related: #push, #pop, #shift.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Array;TcRDoc::NormalClass0[@FI" unshift;TPK]>f3  map-i.rinu[U:RDoc::AnyMethod[iI"map:ETI"Array#map;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"=Calls the block, if given, with each element of +self+; ;TI"Nreturns a new \Array whose elements are the return values from the block:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"+a1 = a.map {|element| element.class } ;TI"'a1 # => [Symbol, String, Integer] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a.map ;TI"1a1 # => # ;T; 0o; ; [I"-Array#collect is an alias for Array#map.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI" Array;TcRDoc::NormalClass0[@"FI" collect;TPK]6Z" compact-i.rinu[U:RDoc::AnyMethod[iI" compact:ETI"Array#compact;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"HReturns a new \Array containing all non-+nil+ elements from +self+:;To:RDoc::Markup::Verbatim; [I"'a = [nil, 0, nil, 1, nil, 2, nil] ;TI"a.compact # => [0, 1, 2];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I" array.compact -> new_array ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]x˼z]]%5b%5d%3d-i.rinu[U:RDoc::AnyMethod[iI"[]=:ETI"Array#[]=;TF: privateo:RDoc::Markup::Document: @parts[%o:RDoc::Markup::Paragraph; [I" "foo" ;TI"a # => ["foo", "bar", 2] ;T: @format0o; ; [I"HIf +index+ is greater than self.length, extends the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a[7] = 'foo' # => "foo" ;TI"8a # => [:foo, "bar", 2, nil, nil, nil, nil, "foo"] ;T; 0o; ; [I"HIf +index+ is negative, counts backwards from the end of the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a[-1] = 'two' # => "two" ;TI"!a # => [:foo, "bar", "two"] ;T; 0o; ; [I"[When \Integer arguments +start+ and +length+ are given and +object+ is not an \Array, ;TI"Gremoves length - 1 elements beginning at offset +start+, ;TI",and assigns +object+ at offset +start+:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[0, 2] = 'foo' # => "foo" ;TI"a # => ["foo", 2] ;T; 0o; ; [I"HIf +start+ is negative, counts backwards from the end of the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"!a[-2, 2] = 'foo' # => "foo" ;TI"a # => [:foo, "foo"] ;T; 0o; ; [I"PIf +start+ is non-negative and outside the array ( >= self.size), ;TI"Gextends the array with +nil+, assigns +object+ at offset +start+, ;TI"and ignores +length+:;To; ; [I"a = [:foo, 'bar', 2] ;TI"!a[6, 50] = 'foo' # => "foo" ;TI"3a # => [:foo, "bar", 2, nil, nil, nil, "foo"] ;T; 0o; ; [I"JIf +length+ is zero, shifts elements at and following offset +start+ ;TI",and assigns +object+ at offset +start+:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[1, 0] = 'foo' # => "foo" ;TI"$a # => [:foo, "foo", "bar", 2] ;T; 0o; ; [I"PIf +length+ is too large for the existing array, does not extend the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[1, 5] = 'foo' # => "foo" ;TI"a # => [:foo, "foo"] ;T; 0o; ; [I"FWhen \Range argument +range+ is given and +object+ is an \Array, ;TI"Gremoves length - 1 elements beginning at offset +start+, ;TI",and assigns +object+ at offset +start+:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[0..1] = 'foo' # => "foo" ;TI"a # => ["foo", 2] ;T; 0o; ; [I"Uif range.begin is negative, counts backwards from the end of the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"!a[-2..2] = 'foo' # => "foo" ;TI"a # => [:foo, "foo"] ;T; 0o; ; [I"range.begin, ;TI"Kassigns +object+ at offset range.begin, and ignores +length+:;To; ; [I"a = [:foo, 'bar', 2] ;TI"!a[6..50] = 'foo' # => "foo" ;TI"3a # => [:foo, "bar", 2, nil, nil, nil, "foo"] ;T; 0o; ; [I"TIf range.end is zero, shifts elements at and following offset +start+ ;TI",and assigns +object+ at offset +start+:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[1..0] = 'foo' # => "foo" ;TI"$a # => [:foo, "foo", "bar", 2] ;T; 0o; ; [I"LIf range.end is negative, assigns +object+ at offset +start+, ;TI"Tretains range.end.abs -1 elements past that, and removes those beyond:;To; ; [I"a = [:foo, 'bar', 2] ;TI"!a[1..-1] = 'foo' # => "foo" ;TI"a # => [:foo, "foo"] ;TI"a = [:foo, 'bar', 2] ;TI"!a[1..-2] = 'foo' # => "foo" ;TI"a # => [:foo, "foo", 2] ;TI"a = [:foo, 'bar', 2] ;TI"!a[1..-3] = 'foo' # => "foo" ;TI"$a # => [:foo, "foo", "bar", 2] ;TI"a = [:foo, 'bar', 2] ;T; 0o; ; [I"@If range.end is too large for the existing array, ;TI"Nreplaces array elements, but does not extend the array with +nil+ values:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[1..5] = 'foo' # => "foo" ;TI"a # => [:foo, "foo"];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"marray[index] = object -> object array[start, length] = object -> object array[range] = object -> object ;T0[I" (*args);T@FI" Array;TcRDoc::NormalClass00PK]"%7c-i.rinu[U:RDoc::AnyMethod[iI"|:ETI" Array#|;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"eql?:;To:RDoc::Markup::Verbatim; [I"'[0, 1] | [2, 3] # => [0, 1, 2, 3] ;TI"-[0, 1, 1] | [2, 2, 3] # => [0, 1, 2, 3] ;TI"0[0, 1, 2] | [3, 2, 1, 0] # => [0, 1, 2, 3] ;T: @format0o; ; [I"Related: Array#union.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"&array | other_array -> new_array ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]Iw reject-i.rinu[U:RDoc::AnyMethod[iI" reject:ETI"Array#reject;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"CReturns a new \Array whose elements are all those from +self+ ;TI"2for which the block returns +false+ or +nil+:;To:RDoc::Markup::Verbatim; [I"!a = [:foo, 'bar', 2, 'bat'] ;TI">a1 = a.reject {|element| element.to_s.start_with?('b') } ;TI"a1 # => [:foo, 2] ;T: @format0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [:foo, 'bar', 2] ;TI"9a.reject # => #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Oarray.reject {|element| ... } -> new_array array.reject -> new_enumerator ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]#UUflatten%21-i.rinu[U:RDoc::AnyMethod[iI" flatten!:ETI"Array#flatten!;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"OReplaces each nested \Array in +self+ with the elements from that \Array; ;TI"4returns +self+ if any changes, +nil+ otherwise.;To:RDoc::Markup::BlankLineo; ; [I"^With non-negative \Integer argument +level+, flattens recursively through +level+ levels:;To:RDoc::Markup::Verbatim; [ I"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"-a.flatten!(1) # => [0, 1, [2, 3], 4, 5] ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"+a.flatten!(2) # => [0, 1, 2, 3, 4, 5] ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"+a.flatten!(3) # => [0, 1, 2, 3, 4, 5] ;TI"$[0, 1, 2].flatten!(1) # => nil ;T: @format0o; ; [I"`With no argument, a +nil+ argument, or with negative argument +level+, flattens all levels:;To; ; [ I"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI"(a.flatten! # => [0, 1, 2, 3, 4, 5] ;TI"![0, 1, 2].flatten! # => nil ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI",a.flatten!(-1) # => [0, 1, 2, 3, 4, 5] ;TI"$a = [ 0, [ 1, [2, 3], 4 ], 5 ] ;TI",a.flatten!(-2) # => [0, 1, 2, 3, 4, 5] ;TI"$[0, 1, 2].flatten!(-1) # => nil;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Harray.flatten! -> self or nil array.flatten!(level) -> self or nil ;T0[I" (*args);T@)FI" Array;TcRDoc::NormalClass00PK]_>  permutation-i.rinu[U:RDoc::AnyMethod[iI"permutation:ETI"Array#permutation;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"^When invoked with a block, yield all permutations of elements of +self+; returns +self+. ;TI"0The order of permutations is indeterminate.;To:RDoc::Markup::BlankLineo; ; [I"_When a block and an in-range positive \Integer argument +n+ (0 < n <= self.size) ;TI"Jare given, calls the block with all +n+-tuple permutations of +self+.;T@o; ; [I" Example:;To:RDoc::Markup::Verbatim; [I"a = [0, 1, 2] ;TI"5a.permutation(2) {|permutation| p permutation } ;T: @format0o; ; [I" Output:;To; ; [ I" [0, 1] ;TI" [0, 2] ;TI" [1, 0] ;TI" [1, 2] ;TI" [2, 0] ;TI" [2, 1] ;T; 0o; ; [I"Another example:;To; ; [I"a = [0, 1, 2] ;TI"5a.permutation(3) {|permutation| p permutation } ;T; 0o; ; [I" Output:;To; ; [ I"[0, 1, 2] ;TI"[0, 2, 1] ;TI"[1, 0, 2] ;TI"[1, 2, 0] ;TI"[2, 0, 1] ;TI"[2, 1, 0] ;T; 0o; ; [I"DWhen +n+ is zero, calls the block once with a new empty \Array:;To; ; [I"a = [0, 1, 2] ;TI"5a.permutation(0) {|permutation| p permutation } ;T; 0o; ; [I" Output:;To; ; [I"[] ;T; 0o; ; [I"LWhen +n+ is out of range (negative or larger than self.size), ;TI"does not call the block:;To; ; [I"a = [0, 1, 2] ;TI"=a.permutation(-1) {|permutation| fail 'Cannot happen' } ;TI"a.permutation(a.size):;To; ; [I"a = [0, 1, 2] ;TI"2a.permutation {|permutation| p permutation } ;T; 0o; ; [I" Output:;To; ; [ I"[0, 1, 2] ;TI"[0, 2, 1] ;TI"[1, 0, 2] ;TI"[1, 2, 0] ;TI"[2, 0, 1] ;TI"[2, 1, 0] ;T; 0o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I"a = [0, 1, 2] ;TI"=a.permutation # => # ;TI"Ba.permutation(2) # => #;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array.permutation {|element| ... } -> self array.permutation(n) {|element| ... } -> self array.permutation -> new_enumerator array.permutation(n) -> new_enumerator ;T0[I" (*args);T@iFI" Array;TcRDoc::NormalClass00PK]g<''transpose-i.rinu[U:RDoc::AnyMethod[iI"transpose:ETI"Array#transpose;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"=Transposes the rows and columns in an \Array of Arrays; ;TI"1the nested Arrays must all be the same size:;To:RDoc::Markup::Verbatim; [I".a = [[:a0, :a1], [:b0, :b1], [:c0, :c1]] ;TI"8a.transpose # => [[:a0, :b0, :c0], [:a1, :b1, :c1]];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I""array.transpose -> new_array ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]\  select%21-i.rinu[U:RDoc::AnyMethod[iI" select!:ETI"Array#select!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"=Calls the block, if given with each element of +self+; ;TI"Uremoves from +self+ those elements for which the block returns +false+ or +nil+.;To:RDoc::Markup::BlankLineo; ; [I"1Returns +self+ if any elements were removed:;To:RDoc::Markup::Verbatim; [I" a = [:foo, 'bar', 2, :bam] ;TI"Ma.select! {|element| element.to_s.start_with?('b') } # => ["bar", :bam] ;T: @format0o; ; [I"/Returns +nil+ if no elements were removed.;T@o; ; [I"1Returns a new \Enumerator if no block given:;To; ; [I" a = [:foo, 'bar', 2, :bam] ;TI"Ba.select! # => # ;T; 0o; ; [I"1Array#filter! is an alias for Array#select!.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Sarray.select! {|element| ... } -> self or nil array.select! -> new_enumerator ;T0[[I" filter!;T@ I"();T@$FI" Array;TcRDoc::NormalClass00PK]H,compact%21-i.rinu[U:RDoc::AnyMethod[iI" compact!:ETI"Array#compact!;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I",Removes all +nil+ elements from +self+.;To:RDoc::Markup::BlankLineo; ; [I"=Returns +self+ if any elements removed, otherwise +nil+.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"#array.compact! -> self or nil ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]rBB union-i.rinu[U:RDoc::AnyMethod[iI" union:ETI"Array#union;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"[Returns a new \Array that is the union of +self+ and all given Arrays +other_arrays+; ;TI"Zduplicates are removed; order is preserved; items are compared using eql?:;To:RDoc::Markup::Verbatim; [I"F[0, 1, 2, 3].union([4, 5], [6, 7]) # => [0, 1, 2, 3, 4, 5, 6, 7] ;TI"7[0, 1, 1].union([2, 1], [3, 1]) # => [0, 1, 2, 3] ;TI":[0, 1, 2, 3].union([3, 2], [1, 0]) # => [0, 1, 2, 3] ;T: @format0o; ; [I"4Returns a copy of +self+ if no arguments given.;To:RDoc::Markup::BlankLineo; ; [I"Related: Array#|.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"-array.union(*other_arrays) -> new_array ;T0[I" (*args);T@FI" Array;TcRDoc::NormalClass00PK]Fv<%2b-i.rinu[U:RDoc::AnyMethod[iI"+:ETI" Array#+;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"=Returns a new \Array containing all elements of +array+ ;TI"/followed by all elements of +other_array+:;To:RDoc::Markup::Verbatim; [I"a = [0, 1] + [2, 3] ;TI"a # => [0, 1, 2, 3] ;T: @format0o; ; [I"Related: #concat.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"&array + other_array -> new_array ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]WX$$ each-i.rinu[U:RDoc::AnyMethod[iI" each:ETI"Array#each;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I""Iterates over array elements.;To:RDoc::Markup::BlankLineo; ; [I"LWhen a block given, passes each successive array element to the block; ;TI"returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"=a.each {|element| puts "#{element.class} #{element}" } ;T: @format0o; ; [I" Output:;To; ; [I"Symbol foo ;TI"String bar ;TI"Integer 2 ;T; 0o; ; [I"6Allows the array to be modified during iteration:;To; ; [I"a = [:foo, 'bar', 2] ;TI"Pa.each {|element| puts element; a.clear if element.to_s.start_with?('b') } ;T; 0o; ; [I" Output:;To; ; [I" foo ;TI" bar ;T; 0o; ; [I"4When no block given, returns a new \Enumerator:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"e = a.each ;TI"1e # => # ;TI"Ba1 = e.each {|element| puts "#{element.class} #{element}" } ;T; 0o; ; [I" Output:;To; ; [I"Symbol foo ;TI"String bar ;TI"Integer 2 ;T; 0o; ; [I")Related: #each_index, #reverse_each.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Barray.each {|element| ... } -> self array.each -> Enumerator ;T0[I"();T@AFI" Array;TcRDoc::NormalClass00PK]ۧ0initialize_copy-i.rinu[U:RDoc::AnyMethod[iI"initialize_copy:ETI"Array#initialize_copy;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"VReplaces the content of +self+ with the content of +other_array+; returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"6a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"(array.replace(other_array) -> self ;T0[[I" replace;T@ I" (p1);T@FI" Array;TcRDoc::NormalClass00PK][%2d-i.rinu[U:RDoc::AnyMethod[iI"-:ETI" Array#-;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"FReturns a new \Array containing only those elements from +array+ ;TI"1that are not found in \Array +other_array+; ;TI"-items are compared using eql?; ;TI")the order from +array+ is preserved:;To:RDoc::Markup::Verbatim; [I"6[0, 1, 1, 2, 1, 1, 3, 1, 1] - [1] # => [0, 2, 3] ;TI"'[0, 1, 2, 3] - [3, 0] # => [1, 2] ;TI"$[0, 1, 2] - [4] # => [0, 1, 2] ;T: @format0o; ; [I"Related: Array#difference.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"&array - other_array -> new_array ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]-bodd to_h-i.rinu[U:RDoc::AnyMethod[iI" to_h:ETI"Array#to_h;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I",Returns a new \Hash formed from +self+.;To:RDoc::Markup::BlankLineo; ; [I"EWhen a block is given, calls the block with each array element; ;TI"Athe block must return a 2-element \Array whose two elements ;TI"1form a key-value pair in the returned \Hash:;To:RDoc::Markup::Verbatim; [I",a = ['foo', :bar, 1, [2, 3], {baz: 4}] ;TI"'h = a.to_h {|item| [item, item] } ;TI"Sh # => {"foo"=>"foo", :bar=>:bar, 1=>1, [2, 3]=>[2, 3], {:baz=>4}=>{:baz=>4}} ;T: @format0o; ; [I"OWhen no block is given, +self+ must be an \Array of 2-element sub-arrays, ;TI"Eeach sub-array is formed into a key-value pair in the new \Hash:;To; ; [ I"[].to_h # => {} ;TI";a = [['foo', 'zero'], ['bar', 'one'], ['baz', 'two']] ;TI"h = a.to_h ;TI"7h # => {"foo"=>"zero", "bar"=>"one", "baz"=>"two"};T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Aarray.to_h -> new_hash array.to_h {|item| ... } -> new_hash ;T0[I"();T@#FI" Array;TcRDoc::NormalClass00PK]Mhh %3c%3c-i.rinu[U:RDoc::AnyMethod[iI"<<:ETI" Array#<<;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"0Appends +object+ to +self+; returns +self+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"+a << :baz # => [:foo, "bar", 2, :baz] ;T: @format0o; ; [I"CAppends +object+ as one element, even if it is another \Array:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a1 = a << [3, 4] ;TI"%a1 # => [:foo, "bar", 2, [3, 4]];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array << object -> self ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]Z cycle-i.rinu[U:RDoc::AnyMethod[iI" cycle:ETI"Array#cycle;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"FWhen called with positive \Integer argument +count+ and a block, ;TI" nil ;TI"output # => [0, 1, 0, 1] ;T: @format0o; ; [I"=If +count+ is zero or negative, does not call the block:;To; ; [I"@[0, 1].cycle(0) {|element| fail 'Cannot happen' } # => nil ;TI"A[0, 1].cycle(-1) {|element| fail 'Cannot happen' } # => nil ;T; 0o; ; [I"MWhen a block is given, and argument is omitted or +nil+, cycles forever:;To; ; [I"# Prints 0 and 1 forever. ;TI",[0, 1].cycle {|element| puts element } ;TI"1[0, 1].cycle(nil) {|element| puts element } ;T; 0o; ; [I"7When no block is given, returns a new \Enumerator:;To:RDoc::Markup::BlankLineo; ; [I"9[0, 1].cycle(2) # => # ;TI"8[0, 1].cycle # => # => # ;TI"/[0, 1].cycle.first(5) # => [0, 1, 0, 1, 0];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array.cycle {|element| ... } -> nil array.cycle(count) {|element| ... } -> nil array.cycle -> new_enumerator array.cycle(count) -> new_enumerator ;T0[I" (*args);T@-FI" Array;TcRDoc::NormalClass00PK]^ minmax-i.rinu[U:RDoc::AnyMethod[iI" minmax:ETI"Array#minmax;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"NReturns a new 2-element \Array containing the minimum and maximum values ;TI"Gfrom +self+, either per method <=> or per a given block:.;To:RDoc::Markup::BlankLineo; ; [ I"XWhen no block is given, each element in +self+ must respond to method <=> ;TI"with an \Integer; ;TI"Nreturns a new 2-element \Array containing the minimum and maximum values ;TI"*from +self+, per method <=>:;To:RDoc::Markup::Verbatim; [I""[0, 1, 2].minmax # => [0, 2] ;T: @format0o; ; [ I"?When a block is given, the block must return an \Integer; ;TI"Ithe block is called self.size-1 times to compare elements; ;TI"Nreturns a new 2-element \Array containing the minimum and maximum values ;TI" from +self+, per the block:;To; ; [I"L['0', '00', '000'].minmax {|a, b| a.size <=> b.size } # => ["0", "000"];T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"Yarray.minmax -> [min_val, max_val] array.minmax {|a, b| ... } -> [min_val, max_val] ;T0[I"();T@"FI" Array;TcRDoc::NormalClass00PK]D   %3d%3d-i.rinu[U:RDoc::AnyMethod[iI"==:ETI" Array#==;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"DReturns +true+ if both array.size == other_array.size ;TI"Land for each index +i+ in +array+, array[i] == other_array[i]:;To:RDoc::Markup::Verbatim; [ I"a0 = [:foo, 'bar', 2] ;TI"a1 = [:foo, 'bar', 2.0] ;TI"a1 == a0 # => true ;TI"[] == [] # => true ;T: @format0o; ; [I" Otherwise, returns +false+.;To:RDoc::Markup::BlankLineo; ; [I"6This method is different from method Array#eql?, ;TI"8which compares elements using Object#eql?.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"+array == other_array -> true or false ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]kdelete_at-i.rinu[U:RDoc::AnyMethod[iI"delete_at:ETI"Array#delete_at;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DDeletes an element from +self+, per the given \Integer +index+.;To:RDoc::Markup::BlankLineo; ; [I"IWhen +index+ is non-negative, deletes the element at offset +index+:;To:RDoc::Markup::Verbatim; [I"a = [:foo, 'bar', 2] ;TI"a.delete_at(1) # => "bar" ;TI"a # => [:foo, 2] ;T: @format0o; ; [I"*If index is too large, returns +nil+.;T@o; ; [I"IWhen +index+ is negative, counts backward from the end of the array:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a.delete_at(-2) # => "bar" ;TI"a # => [:foo, 2] ;T; 0o; ; [I":If +index+ is too small (far from zero), returns nil.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"5array.delete_at(index) -> deleted_object or nil ;T0[I" (p1);T@%FI" Array;TcRDoc::NormalClass00PK]|^# assoc-i.rinu[U:RDoc::AnyMethod[iI" assoc:ETI"Array#assoc;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I";Returns the first element in +self+ that is an \Array ;TI"+whose first element == +obj+:;To:RDoc::Markup::Verbatim; [I"/a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] ;TI"a.assoc(4) # => [4, 5, 6] ;T: @format0o; ; [I"/Returns +nil+ if no such element is found.;To:RDoc::Markup::BlankLineo; ; [I"Related: #rassoc.;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I",array.assoc(obj) -> found_array or nil ;T0[I" (p1);T@FI" Array;TcRDoc::NormalClass00PK]WAH%3c%3d%3e-i.rinu[U:RDoc::AnyMethod[iI"<=>:ETI"Array#<=>;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"ZReturns -1, 0, or 1 as +self+ is less than, equal to, or greater than +other_array+. ;TI"ZFor each index +i+ in +self+, evaluates result = self[i] <=> other_array[i].;To:RDoc::Markup::BlankLineo; ; [I"$Returns -1 if any result is -1:;To:RDoc::Markup::Verbatim; [I"%[0, 1, 2] <=> [0, 1, 3] # => -1 ;T: @format0o; ; [I""Returns 1 if any result is 1:;To; ; [I"$[0, 1, 2] <=> [0, 1, 1] # => 1 ;T; 0o; ; [I"When all results are zero:;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"9Returns -1 if +array+ is smaller than +other_array+:;To; ; [I"([0, 1, 2] <=> [0, 1, 2, 3] # => -1 ;T; 0o;;0; [o; ; [I"7Returns 1 if +array+ is larger than +other_array+:;To; ; [I"![0, 1, 2] <=> [0, 1] # => 1 ;T; 0o;;0; [o; ; [I">Returns 0 if +array+ and +other_array+ are the same size:;To; ; [I"#[0, 1, 2] <=> [0, 1, 2] # => 0;T; 0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"*array <=> other_array -> -1, 0, or 1 ;T0[I" (p1);T@9FI" Array;TcRDoc::NormalClass00PK]@ reverse-i.rinu[U:RDoc::AnyMethod[iI" reverse:ETI"Array#reverse;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GReturns a new \Array with the elements of +self+ in reverse order.;To:RDoc::Markup::Verbatim; [I"a = ['foo', 'bar', 'two'] ;TI"a1 = a.reverse ;TI""a1 # => ["two", "bar", "foo"];T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I" array.reverse -> new_array ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]'UU hash-i.rinu[U:RDoc::AnyMethod[iI" hash:ETI"Array#hash;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"/Returns the integer hash value for +self+.;To:RDoc::Markup::BlankLineo; ; [I"aTwo arrays with the same content will have the same hash code (and will compare using eql?):;To:RDoc::Markup::Verbatim; [I"0[0, 1, 2].hash == [0, 1, 2].hash # => true ;TI"0[0, 1, 2].hash == [0, 1, 3].hash # => false;T: @format0: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"array.hash -> integer ;T0[I"();T@FI" Array;TcRDoc::NormalClass00PK]' abbrev-i.rinu[U:RDoc::AnyMethod[iI" abbrev:ETI"Array#abbrev;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"OCalculates the set of unambiguous abbreviations for the strings in +self+.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"require 'abbrev' ;TI"%w{ car cone }.abbrev ;TI"R#=> {"car"=>"car", "ca"=>"car", "cone"=>"cone", "con"=>"cone", "co"=>"cone"} ;T: @format0o; ; [I"KThe optional +pattern+ parameter is a pattern or a string. Only input ;TI"Qstrings that match the pattern or start with the string are included in the ;TI"output hash.;T@o; ; [ I"'%w{ fast boat day }.abbrev(/^.a/) ;TI"R#=> {"fast"=>"fast", "fas"=>"fast", "fa"=>"fast", "day"=>"day", "da"=>"day"} ;TI" ;TI"+Abbrev.abbrev(%w{car box cone}, "ca") ;TI"%#=> {"car"=>"car", "ca"=>"car"} ;T; 0o; ; [I"See also Abbrev.abbrev;T: @fileI"lib/abbrev.rb;T:0@omit_headings_from_table_of_contents_below000[I"(pattern = nil);T@#FI" Array;TcRDoc::NormalClass00PK]|ss any%3f-i.rinu[U:RDoc::AnyMethod[iI" any?:ETI"Array#any?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"EReturns +true+ if any element of +self+ meets a given criterion.;To:RDoc::Markup::BlankLineo; ; [I"[With no block given and no argument, returns +true+ if +self+ has any truthy element, ;TI"+false+ otherwise:;To:RDoc::Markup::Verbatim; [I"$[nil, 0, false].any? # => true ;TI""[nil, false].any? # => false ;TI"[].any? # => false ;T: @format0o; ; [I"VWith a block given and no argument, calls the block with each element in +self+; ;TI"Mreturns +true+ if the block returns any truthy value, +false+ otherwise:;To; ; [I"7[0, 1, 2].any? {|element| element > 1 } # => true ;TI"8[0, 1, 2].any? {|element| element > 2 } # => false ;T; 0o; ; [I"SIf argument +obj+ is given, returns +true+ if +obj+.=== any element, ;TI"+false+ otherwise:;To; ; [ I"-['food', 'drink'].any?(/foo/) # => true ;TI".['food', 'drink'].any?(/bar/) # => false ;TI"[].any?(/foo/) # => false ;TI"![0, 1, 2].any?(1) # => true ;TI""[0, 1, 2].any?(3) # => false ;T; 0o; ; [I"Related: Enumerable#any?;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below0I"oarray.any? -> true or false array.any? {|element| ... } -> true or false array.any?(obj) -> true or false ;T0[I" (*args);T@.FI" Array;TcRDoc::NormalClass00PK]"K slice-i.rinu[U:RDoc::AnyMethod[iI" slice:ETI"Array#slice;TF: privateo:RDoc::Markup::Document: @parts[&o:RDoc::Markup::Paragraph; [I":Returns elements from +self+; does not modify +self+.;To:RDoc::Markup::BlankLineo; ; [I"]When a single \Integer argument +index+ is given, returns the element at offset +index+:;To:RDoc::Markup::Verbatim; [ I"a = [:foo, 'bar', 2] ;TI"a[0] # => :foo ;TI"a[2] # => 2 ;TI"a # => [:foo, "bar", 2] ;T: @format0o; ; [I"BIf +index+ is negative, counts relative to the end of +self+:;To; ; [I"a = [:foo, 'bar', 2] ;TI"a[-1] # => 2 ;TI"a[-2] # => "bar" ;T; 0o; ; [I"/If +index+ is out of range, returns +nil+.;T@o; ; [I"AWhen two \Integer arguments +start+ and +length+ are given, ;TI"freturns a new \Array of size +length+ containing successive elements beginning at offset +start+:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[0, 2] # => [:foo, "bar"] ;TI"a[1, 2] # => ["bar", 2] ;T; 0o; ; [I"FIf start + length is greater than self.length, ;TI"9returns all elements from offset +start+ to the end:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"#a[0, 4] # => [:foo, "bar", 2] ;TI"a[1, 3] # => ["bar", 2] ;TI"a[2, 2] # => [2] ;T; 0o; ; [I">If start == self.size and length >= 0, ;TI" returns a new empty \Array.;T@o; ; [I",If +length+ is negative, returns +nil+.;T@o; ; [I"5When a single \Range argument +range+ is given, ;TI"0treats range.min as +start+ above ;TI"/and range.size as +length+ above:;To; ; [I"a = [:foo, 'bar', 2] ;TI" a[0..1] # => [:foo, "bar"] ;TI"a[1..2] # => ["bar", 2] ;T; 0o; ; [I"QSpecial case: If range.start == a.size, returns a new empty \Array.;T@o; ; [I"NIf range.end is negative, calculates the end index from the end:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"$a[0..-1] # => [:foo, "bar", 2] ;TI"!a[0..-2] # => [:foo, "bar"] ;TI"a[0..-3] # => [:foo] ;T; 0o; ; [I"RIf range.start is negative, calculates the start index from the end:;To; ; [ I"a = [:foo, 'bar', 2] ;TI"a[-1..2] # => [2] ;TI"a[-2..2] # => ["bar", 2] ;TI"$a[-3..2] # => [:foo, "bar", 2] ;T; 0o; ; [I"JIf range.start is larger than the array size, returns +nil+.;To; ; [ I"a = [:foo, 'bar', 2] ;TI"a[4..1] # => nil ;TI"a[4..0] # => nil ;TI"a[4..-1] # => nil ;T; 0o; ; [I"LWhen a single Enumerator::ArithmeticSequence argument +aseq+ is given, ;TI"Kreturns an Array of elements corresponding to the indexes produced by ;TI"the sequence.;To; ; [I"7a = ['--', 'data1', '--', 'data2', '--', 'data3'] ;TI"7a[(1..).step(2)] # => ["data1", "data2", "data3"] ;T; 0o; ; [I"SUnlike slicing with range, if the start or the end of the arithmetic sequence ;TI"2is larger than array size, throws RangeError.;To; ; [ I"7a = ['--', 'data1', '--', 'data2', '--', 'data3'] ;TI"a[(1..11).step(2)] ;TI"3# RangeError (((1..11).step(2)) out of range) ;TI"a[(7..).step(2)] ;TI"1# RangeError (((7..).step(2)) out of range) ;T; 0o; ; [I"QIf given a single argument, and its type is not one of the listed, tries to ;TI";convert it to Integer, and raises if it is impossible:;To; ; [I"a = [:foo, 'bar', 2] ;TI"I# Raises TypeError (no implicit conversion of Symbol into Integer): ;TI" a[:foo] ;T; 0o; ; [I"*Array#slice is an alias for Array#[].;T: @fileI" array.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@FI" Array;TcRDoc::NormalClass0[@FI"[];TPK]CYY length-i.rinu[PK]T,||zip-i.rinu[PK] H fill-i.rinu[PK]) {*map%21-i.rinu[PK]aZZ-difference-i.rinu[PK]?Zhh61values_at-i.rinu[PK]l 7uniq%21-i.rinu[PK]x/;;<take_while-i.rinu[PK]|tAtry_convert-c.rinu[PK]I $$uDdig-i.rinu[PK]v2YYGsort_by%21-i.rinu[PK] |  binclude%3f-i.rinu[PK]: dpush-i.rinu[PK]: hdrop-i.rinu[PK]9[[ jkcollect-i.rinu[PK]2 oconcat-i.rinu[PK]YD -qproduct-i.rinu[PK]D?zeach_index-i.rinu[PK]T'"ll xunshift-i.rinu[PK] reverse%21-i.rinu[PK]Fx slice%21-i.rinu[PK]֍=ff܍reverse_each-i.rinu[PK]y1Feecollect%21-i.rinu[PK]qN'filter%21-i.rinu[PK]l4intersection-i.rinu[PK]#   one%3f-i.rinu[PK]v  @max-i.rinu[PK].ܑ bsearch-i.rinu[PK]; join-i.rinu[PK]g 66 size-i.rinu[PK]꜖ 0select-i.rinu[PK]IGKKsum-i.rinu[PK]7--repeated_combination-i.rinu[PK]9\ %5b%5d-i.rinu[PK]Gv>-at-i.rinu[PK]Bۈ 8count-i.rinu[PK]F to_s-i.rinu[PK]!yy Idelete-i.rinu[PK]y9oo index-i.rinu[PK]"b1xx all%3f-i.rinu[PK]l||Yintersect%3f-i.rinu[PK]|h   uniq-i.rinu[PK]N \min-i.rinu[PK]R+g  shelljoin-i.rinu[PK]Vfind_index-i.rinu[PK]`hh last-i.rinu[PK])M drop_while-i.rinu[PK]2delete_if-i.rinu[PK]== sort%21-i.rinu[PK] ,h zrassoc-i.rinu[PK]I FF 5prepend-i.rinu[PK]>f3  map-i.rinu[PK]6Z" "compact-i.rinu[PK]x˼z]]%%5b%5d%3d-i.rinu[PK]"5%7c-i.rinu[PK]Iw p8reject-i.rinu[PK]#UU;flatten%21-i.rinu[PK]_>  CApermutation-i.rinu[PK]g<''Jtranspose-i.rinu[PK]\  Mselect%21-i.rinu[PK]H,LQcompact%21-i.rinu[PK]rBB =Sunion-i.rinu[PK]Fv<V%2b-i.rinu[PK]WX$$ Xeach-i.rinu[PK]ۧ0U^initialize_copy-i.rinu[PK][`%2d-i.rinu[PK]-bodd cto_h-i.rinu[PK]Mhh Qh%3c%3c-i.rinu[PK]Z jcycle-i.rinu[PK]^ pminmax-i.rinu[PK]D   u%3d%3d-i.rinu[PK]kydelete_at-i.rinu[PK]|^# |assoc-i.rinu[PK]WAH%3c%3d%3e-i.rinu[PK]@ reverse-i.rinu[PK]'UU Ɔhash-i.rinu[PK]' Tabbrev-i.rinu[PK]|ss any%3f-i.rinu[PK]"K -slice-i.rinu[PKss"E