D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Array
/
Filename :
cdesc-Array.ri
back
Copy
U:RDoc::NormalClass[iI" Array:ET@I"Object;To:RDoc::Markup::Document:@parts[ o;;[�o:RDoc::Markup::Paragraph;[ I"LAn \Array object is an ordered, integer-indexed collection of objects, ;TI"called _elements_; ;TI"the object represents ;TI"Uan {array data structure}[https://en.wikipedia.org/wiki/Array_(data_structure)].;To:RDoc::Markup::BlankLine o; ;[I"8An element may be any object (even another array); ;TI"?elements may be any mixture of objects of different types.;T@o; ;[I"7Important data structures that use arrays include:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"J{Coordinate vector}[https://en.wikipedia.org/wiki/Coordinate_vector].;To;;0;[o; ;[I"B{Matrix}[https://en.wikipedia.org/wiki/Matrix_(mathematics)].;To;;0;[o; ;[I"A{Heap}[https://en.wikipedia.org/wiki/Heap_(data_structure)].;To;;0;[o; ;[I"<{Hash table}[https://en.wikipedia.org/wiki/Hash_table].;To;;0;[o; ;[I"T{Deque (double-ended queue)}[https://en.wikipedia.org/wiki/Double-ended_queue].;To;;0;[o; ;[I"G{Queue}[https://en.wikipedia.org/wiki/Queue_(abstract_data_type)].;To;;0;[o; ;[I"G{Stack}[https://en.wikipedia.org/wiki/Stack_(abstract_data_type)].;T@o; ;[I"/There are also array-like data structures:;T@o;;; ;[ o;;0;[o; ;[I"U{Associative array}[https://en.wikipedia.org/wiki/Associative_array] (see Hash).;To;;0;[o; ;[I"P{Directory}[https://en.wikipedia.org/wiki/Directory_(computing)] (see Dir).;To;;0;[o; ;[I"Q{Environment}[https://en.wikipedia.org/wiki/Environment_variable] (see ENV).;To;;0;[o; ;[I"M{Set}[https://en.wikipedia.org/wiki/Set_(abstract_data_type)] (see Set).;To;;0;[o; ;[I"T{String}[https://en.wikipedia.org/wiki/String_(computer_science)] (see String).;T@S:RDoc::Markup::Heading: leveli: textI"\Array Indexes;T@o; ;[I"2\Array indexing starts at 0, as in C or Java.;T@o; ;[I">A non-negative index is an offset from the first element:;T@o;;; ;[o;;0;[o; ;[I")Index 0 indicates the first element.;To;;0;[o; ;[I"*Index 1 indicates the second element.;To;;0;[o; ;[I"...;T@o; ;[I"IA negative index is an offset, backwards, from the end of the array:;T@o;;; ;[o;;0;[o; ;[I")Index -1 indicates the last element.;To;;0;[o; ;[I"1Index -2 indicates the next-to-last element.;To;;0;[o; ;[I"...;T@S;;i;I"&In-Range and Out-of-Range Indexes;T@o; ;[I"OA non-negative index is <i>in range</i> if and only if it is smaller than ;TI"3the size of the array. For a 3-element array:;T@o;;; ;[o;;0;[o; ;[I"&Indexes 0 through 2 are in range.;To;;0;[o; ;[I"Index 3 is out of range.;T@o; ;[I"NA negative index is <i>in range</i> if and only if its absolute value is ;TI"Cnot larger than the size of the array. For a 3-element array:;T@o;;; ;[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"Effective Index;T@o; ;[ I"FAlthough the effective index into an array is always an integer, ;TI";some methods (both within class \Array and elsewhere) ;TI"7accept one or more non-integer arguments that are ;TI"b{integer-convertible objects}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects].;T@S;;i;I"Creating Arrays;T@o; ;[I"5You can create an \Array object explicitly with:;T@o;;; ;[ o;;0;[o; ;[I"FAn {array literal}[rdoc-ref:syntax/literals.rdoc@Array+Literals]:;T@o:RDoc::Markup::Verbatim;[I"([1, 'one', :one, [2, 'two', :two]] ;T:@format0o;;0;[o; ;[I"lA {%w or %W string-array Literal}[rdoc-ref:syntax/literals.rdoc@25w+and+-25W-3A+String-Array+Literals]:;T@o;;[I"0%w[foo bar baz] # => ["foo", "bar", "baz"] ;TI"*%w[1 % *] # => ["1", "%", "*"] ;T;0o;;0;[o; ;[I"lA {%i or %I symbol-array Literal}[rdoc-ref:syntax/literals.rdoc@25i+and+-25I-3A+Symbol-Array+Literals]:;T@o;;[I"-%i[foo bar baz] # => [:foo, :bar, :baz] ;TI")%i[1 % *] # => [:"1", :%, :*] ;T;0o;;0;[o; ;[I"\Method Kernel#Array:;T@o;;[I"3Array(["a", "b"]) # => ["a", "b"] ;TI"8Array(1..5) # => [1, 2, 3, 4, 5] ;TI"9Array(key: :value) # => [[:key, :value]] ;TI"+Array(nil) # => [] ;TI",Array(1) # => [1] ;TI"?Array({:a => "a", :b => "b"}) # => [[:a, "a"], [:b, "b"]] ;T;0o;;0;[o; ;[I"\Method Array.new:;T@o;;[ I"%Array.new # => [] ;TI"2Array.new(3) # => [nil, nil, nil] ;TI"3Array.new(4) {Hash.new} # => [{}, {}, {}, {}] ;TI"5Array.new(3, true) # => [true, true, true] ;T;0o; ;[ I":Note that the last example above populates the array ;TI")with references to the same object. ;TI"XThis is recommended only in cases where that object is a natively immutable object ;TI"<such as a symbol, a numeric, +nil+, +true+, or +false+.;T@o; ;[I"IAnother way to create an array with various objects, using a block; ;TI"Gthis usage is safe for mutable objects such as hashes, strings or ;TI"other arrays:;T@o;;[I":Array.new(4) {|i| i.to_s } # => ["0", "1", "2", "3"] ;T;0o; ;[I"7Here is a way to create a multi-dimensional array:;T@o;;[I"!Array.new(3) {Array.new(3)} ;TI"># => [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]] ;T;0o; ;[I"MA number of Ruby methods, both in the core and in the standard library, ;TI"Jprovide instance method +to_a+, which converts an object to an array.;T@o;;; ;[o;;0;[o; ;[I"ARGF#to_a;To;;0;[o; ;[I"Array#to_a;To;;0;[o; ;[I"Enumerable#to_a;To;;0;[o; ;[I"Hash#to_a;To;;0;[o; ;[I"MatchData#to_a;To;;0;[o; ;[I"NilClass#to_a;To;;0;[o; ;[I"OptionParser#to_a;To;;0;[o; ;[I"Range#to_a;To;;0;[o; ;[I" Set#to_a;To;;0;[o; ;[I"Struct#to_a;To;;0;[o; ;[I"Time#to_a;To;;0;[o; ;[I"Benchmark::Tms#to_a;To;;0;[o; ;[I"CSV::Table#to_a;To;;0;[o; ;[I"Enumerator::Lazy#to_a;To;;0;[o; ;[I"Gem::List#to_a;To;;0;[o; ;[I"Gem::NameTuple#to_a;To;;0;[o; ;[I"Gem::Platform#to_a;To;;0;[o; ;[I".Gem::RequestSet::Lockfile::Tokenizer#to_a;To;;0;[o; ;[I"Gem::SourceList#to_a;To;;0;[o; ;[I""OpenSSL::X509::Extension#to_a;To;;0;[o; ;[I"OpenSSL::X509::Name#to_a;To;;0;[o; ;[I"Racc::ISet#to_a;To;;0;[o; ;[I"Rinda::RingFinger#to_a;To;;0;[o; ;[I"Ripper::Lexer::Elem#to_a;To;;0;[o; ;[I"%RubyVM::InstructionSequence#to_a;To;;0;[o; ;[I"YAML::DBM#to_a;T@S;;i;I"Example Usage;T@o; ;[I"OIn addition to the methods it mixes in through the Enumerable module, the ;TI"R+Array+ 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"<To return the first +n+ elements of an array, use #take;T@o;;[I"arr.take(3) #=> [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"<arr #=> ['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"NLike 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"Pcase 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"AInherits from {class Object}[rdoc-ref:Object@What-27s+Here].;To;;0;[o; ;[I"FIncludes {module Enumerable}[rdoc-ref:Enumerable@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"F{Creating an Array}[rdoc-ref:Array@Methods+for+Creating+an+Array];To;;0;[o; ;[I"4{Querying}[rdoc-ref:Array@Methods+for+Querying];To;;0;[o; ;[I"6{Comparing}[rdoc-ref:Array@Methods+for+Comparing];To;;0;[o; ;[I"4{Fetching}[rdoc-ref:Array@Methods+for+Fetching];To;;0;[o; ;[I"6{Assigning}[rdoc-ref:Array@Methods+for+Assigning];To;;0;[o; ;[I"4{Deleting}[rdoc-ref:Array@Methods+for+Deleting];To;;0;[o; ;[I"6{Combining}[rdoc-ref:Array@Methods+for+Combining];To;;0;[o; ;[I"6{Iterating}[rdoc-ref:Array@Methods+for+Iterating];To;;0;[o; ;[I"8{Converting}[rdoc-ref:Array@Methods+for+Converting];To;;0;[o; ;[I"1{And more....}[rdoc-ref:Array@Other+Methods];T@S;;i;I"$Methods for Creating an +Array+;T@o;;; ;[o;;0;[o; ;[I"<::[]: Returns a new array populated with given objects.;To;;0;[o; ;[I" ::new: Returns a new array.;To;;0;[o; ;[I"D::try_convert: Returns a new array created from a given object.;T@o; ;[I"@See also {Creating Arrays}[rdoc-ref:Array@Creating+Arrays].;T@S;;i;I"Methods for Querying;T@o;;; ;[o;;0;[o; ;[I"@#all?: Returns whether all elements meet a given criterion.;To;;0;[o; ;[I"@#any?: Returns whether any element meets a given criterion.;To;;0;[o; ;[I"G#count: Returns the count of elements that meet a given criterion.;To;;0;[o; ;[I"4#empty?: Returns whether there are no elements.;To;;0;[o; ;[I"j#find_index (aliased as #index): Returns the index of the first element that meets a given criterion.;To;;0;[o; ;[I"*#hash: Returns the integer hash code.;To;;0;[o; ;[I"G#include?: Returns whether any element <tt>==</tt> a given object.;To;;0;[o; ;[I"?#length (aliased as #size): Returns the count of elements.;To;;0;[o; ;[I"C#none?: Returns whether no element <tt>==</tt> a given object.;To;;0;[o; ;[I"K#one?: Returns whether exactly one element <tt>==</tt> a given object.;To;;0;[o; ;[I"Q#rindex: Returns the index of the last element that meets a given criterion.;T@S;;i;I"Methods for Comparing;T@o;;; ;[o;;0;[o; ;[I"a#<=>: Returns -1, 0, or 1, as +self+ is less than, equal to, or greater than a given object.;To;;0;[o; ;[I"o#==: Returns whether each element in +self+ is <tt>==</tt> to the corresponding element in a given object.;To;;0;[o; ;[I"s#eql?: Returns whether each element in +self+ is <tt>eql?</tt> to the corresponding element in a given object.;T@S;;i;I"Methods for Fetching;T@o; ;[I"(These methods do not modify +self+.;T@o;;; ;[!o;;0;[o; ;[I"]#[] (aliased as #slice): Returns consecutive elements as determined by a given argument.;To;;0;[o; ;[I"g#assoc: Returns the first element that is an array whose first element <tt>==</tt> a given object.;To;;0;[o; ;[I"0#at: Returns the element at a given offset.;To;;0;[o; ;[I"^#bsearch: Returns an element selected via a binary search as determined by a given block.;To;;0;[o; ;[I"q#bsearch_index: Returns the index of an element selected via a binary search as determined by a given block.;To;;0;[o; ;[I"B#compact: Returns an array containing all non-+nil+ elements.;To;;0;[o; ;[I"l#dig: Returns the object in nested objects that is specified by a given index and additional arguments.;To;;0;[o; ;[I"E#drop: Returns trailing elements as determined by a given index.;To;;0;[o; ;[I"K#drop_while: Returns trailing elements as determined by a given block.;To;;0;[o; ;[I"3#fetch: Returns the element at a given offset.;To;;0;[o; ;[I"6#fetch_values: Returns elements at given offsets.;To;;0;[o; ;[I"2#first: Returns one or more leading elements.;To;;0;[o; ;[I"2#last: Returns one or more trailing elements.;To;;0;[o; ;[I"h#max: Returns one or more maximum-valued elements, as determined by <tt>#<=></tt> or a given block.;To;;0;[o; ;[I"h#min: Returns one or more minimum-valued elements, as determined by <tt>#<=></tt> or a given block.;To;;0;[o; ;[I"v#minmax: Returns the minimum-valued and maximum-valued elements, as determined by <tt>#<=></tt> or a given block.;To;;0;[o; ;[I"i#rassoc: Returns the first element that is an array whose second element <tt>==</tt> a given object.;To;;0;[o; ;[I"Q#reject: Returns an array containing elements not rejected by a given block.;To;;0;[o; ;[I"5#reverse: Returns all elements in reverse order.;To;;0;[o; ;[I"O#rotate: Returns all elements with some rotated from one end to the other.;To;;0;[o; ;[I"2#sample: Returns one or more random elements.;To;;0;[o; ;[I"b#select (aliased as #filter): Returns an array containing elements selected by a given block.;To;;0;[o; ;[I"2#shuffle: Returns elements in a random order.;To;;0;[o; ;[I"Z#sort: Returns all elements in an order determined by <tt>#<=></tt> or a given block.;To;;0;[o; ;[I"D#take: Returns leading elements as determined by a given index.;To;;0;[o; ;[I"J#take_while: Returns leading elements as determined by a given block.;To;;0;[o; ;[I"?#uniq: Returns an array containing non-duplicate elements.;To;;0;[o; ;[I"7#values_at: Returns the elements at given offsets.;T@S;;i;I"Methods for Assigning;T@o; ;[I"?These methods add, replace, or reorder elements in +self+.;T@o;;; ;[o;;0;[o; ;[I"#<<: Appends an element.;To;;0;[o; ;[I":#[]=: Assigns specified elements with a given object.;To;;0;[o; ;[I"5#concat: Appends all elements from given arrays.;To;;0;[o; ;[I"?#fill: Replaces specified elements with specified objects.;To;;0;[o; ;[I"W#flatten!: Replaces each nested array in +self+ with the elements from that array.;To;;0;[o; ;[I"n#initialize_copy (aliased as #replace): Replaces the content of +self+ with the content of a given array.;To;;0;[o; ;[I"Q#insert: Inserts given objects at a given offset; does not replace elements.;To;;0;[o; ;[I"2#push (aliased as #append): Appends elements.;To;;0;[o; ;[I";#reverse!: Replaces +self+ with its elements reversed.;To;;0;[o; ;[I"9#rotate!: Replaces +self+ with its elements rotated.;To;;0;[o; ;[I"B#shuffle!: Replaces +self+ with its elements in random order.;To;;0;[o; ;[I"g#sort!: Replaces +self+ with its elements sorted, as determined by <tt>#<=></tt> or a given block.;To;;0;[o; ;[I"Y#sort_by!: Replaces +self+ with its elements sorted, as determined by a given block.;To;;0;[o; ;[I"?#unshift (aliased as #prepend): Prepends leading elements.;T@S;;i;I"Methods for Deleting;T@o; ;[I"8Each of these methods removes elements from +self+:;T@o;;; ;[o;;0;[o; ;[I""#clear: Removes all elements.;To;;0;[o; ;[I"+#compact!: Removes all +nil+ elements.;To;;0;[o; ;[I"7#delete: Removes elements equal to a given object.;To;;0;[o; ;[I"7#delete_at: Removes the element at a given offset.;To;;0;[o; ;[I"=#delete_if: Removes elements specified by a given block.;To;;0;[o; ;[I"?#keep_if: Removes elements not specified by a given block.;To;;0;[o; ;[I"0#pop: Removes and returns the last element.;To;;0;[o; ;[I";#reject!: Removes elements specified by a given block.;To;;0;[o; ;[I"U#select! (aliased as #filter!): Removes elements not specified by a given block.;To;;0;[o; ;[I"4#shift: Removes and returns the first element.;To;;0;[o; ;[I"9#slice!: Removes and returns a sequence of elements.;To;;0;[o; ;[I" #uniq!: Removes duplicates.;T@S;;i;I"Methods for Combining;T@o;;; ;[o;;0;[o; ;[I"U#&: Returns an array containing elements found both in +self+ and a given array.;To;;0;[o; ;[I"f#+: Returns an array containing all elements of +self+ followed by all elements of a given array.;To;;0;[o; ;[I"`#-: Returns an array containing all elements of +self+ that are not found in a given array.;To;;0;[o; ;[I"q#|: Returns an array containing all element of +self+ and all elements of a given array, duplicates removed.;To;;0;[o; ;[I"t#difference: Returns an array containing all elements of +self+ that are not found in any of the given arrays..;To;;0;[o; ;[I"f#intersection: Returns an array containing elements found both in +self+ and in each given array.;To;;0;[o; ;[I"[#product: Returns or yields all combinations of elements from +self+ and given arrays.;To;;0;[o; ;[I"S#reverse: Returns an array containing all elements of +self+ in reverse order.;To;;0;[o; ;[I"u#union: Returns an array containing all elements of +self+ and all elements of given arrays, duplicates removed.;T@S;;i;I"Methods for Iterating;T@o;;; ;[ o;;0;[o; ;[I"�#combination: Calls a given block with combinations of elements of +self+; a combination does not use the same element more than once.;To;;0;[o; ;[I"t#cycle: Calls a given block with each element, then does so again, for a specified number of times, or forever.;To;;0;[o; ;[I"1#each: Passes each element to a given block.;To;;0;[o; ;[I"=#each_index: Passes each element index to a given block.;To;;0;[o; ;[I"�#permutation: Calls a given block with permutations of elements of +self+; a permutation does not use the same element more than once.;To;;0;[o; ;[I"�#repeated_combination: Calls a given block with combinations of elements of +self+; a combination may use the same element more than once.;To;;0;[o; ;[I"�#repeated_permutation: Calls a given block with permutations of elements of +self+; a permutation may use the same element more than once.;To;;0;[o; ;[I"M#reverse_each: Passes each element, in reverse order, to a given block.;T@S;;i;I"Methods for Converting;T@o;;; ;[o;;0;[o; ;[I"e#collect (aliased as #map): Returns an array containing the block return-value for each element.;To;;0;[o; ;[I"S#collect! (aliased as #map!): Replaces each element with a block return-value.;To;;0;[o; ;[I"I#flatten: Returns an array that is a recursive flattening of +self+.;To;;0;[o; ;[I"O#inspect (aliased as #to_s): Returns a new String containing the elements.;To;;0;[o; ;[I"W#join: Returns a newsString containing the elements joined by the field separator.;To;;0;[o; ;[I"B#to_a: Returns +self+ or a new array containing all elements.;To;;0;[o; ;[I"#to_ary: Returns +self+.;To;;0;[o; ;[I"8#to_h: Returns a new hash formed from the elements.;To;;0;[o; ;[I"E#transpose: Transposes +self+, which must be an array of arrays.;To;;0;[o; ;[I"L#zip: Returns a new array of arrays containing +self+ and given arrays.;T@S;;i;I"Other Methods;T@o;;; ;[o;;0;[o; ;[I"&#*: Returns one of the following:;T@o;;; ;[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"$<tt>join(field_separator)</tt>.;T@o;;0;[o; ;[I"6#pack: Packs the elements into a binary sequence.;To;;0;[o; ;[I"U#sum: Returns a sum of elements according to either <tt>+</tt> or a given block.;T: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0o;;[ ;I" array.rb;T;0o;;[ ;I"lib/shellwords.rb;T;0o;;[ ;I"pack.rb;T;0;0;0[ [ [[I"Enumerable;To;;[ ;@�;0I"array.c;T[[I" class;T[[:public[[I"[];T@[I"new;T@[I"try_convert;T@[:protected[ [:private[ [I" instance;T[[;[t[I"&;T@[I"*;T@[I"+;T@[I"-;T@[I"<<;T@[I"<=>;T@[I"==;T@[I"[];T@[I"[]=;T@[I"|;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"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"fetch_values;TI" array.rb;T[I" fill;T@[I"filter;T@[I"filter!;T@[I"find_index;T@[I" first;T@s[I"flatten;T@[I" flatten!;T@[I"freeze;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@s[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;T@s[I"select;T@[I"select!;T@[I"shelljoin;TI"lib/shellwords.rb;T[I" shift;T@[I"shuffle;T@s[I" shuffle!;T@s[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@[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@�@I"lib/mkmf.rb;TI"lib/pp.rb;T@@@cRDoc::TopLevel