to_ary

ary.to_ary â ary Instance Public methods Returns self.

to_a

ary.to_a â ary Instance Public methods Returns self. If called on a subclass of Array, converts the receiver to an Array object.

take_while

ary.take_while { |arr| block } â new_aryary.take_while â Enumerator Instance Public methods Passes elements to the block until the block returns nil or false, then stops iterating and returns an array of all prior elements. If no block is given, an Enumerator is returned instead. See also #drop_while a = [1, 2, 3, 4, 5, 0] a.take_while { |i| i < 3 } #=> [1, 2]

take

ary.take(n) â new_ary Instance Public methods Returns first n elements from the array. If a negative number is given, raises an ArgumentError. See also #drop a = [1, 2, 3, 4, 5, 0] a.take(3) #=> [1, 2, 3]

sort_by!

ary.sort_by! { |obj| block } â aryary.sort_by! â Enumerator Instance Public methods Sorts self in place using a set of keys generated by mapping the values in self through the given block. If no block is given, an Enumerator is returned instead.

sort!

ary.sort! â aryary.sort! { |a, b| block } â ary Instance Public methods Sorts self in place. Comparisons for the sort will be done using the <=> operator or using an optional code block. The block must implement a comparison between a and b, and return -1, when a follows b, 0 when a and b are equivalent, or +1 if b follows a. See also Enumerable#sort_by. a = [ "d", "a", "e", "c", "b" ] a.sort! #=> ["a", "b", "c", "d", "e"] a.sort! { |

sort

ary.sort â new_aryary.sort { |a, b| block } â new_ary Instance Public methods Returns a new array created by sorting self. Comparisons for the sort will be done using the <=> operator or using an optional code block. The block must implement a comparison between a and b, and return -1, when a follows b, 0 when a and b are equivalent, or +1 if b follows a. See also Enumerable#sort_by. a = [ "d", "a", "e", "c", "b" ] a.sort #=> ["a", "b

slice!

ary.slice!(index) â obj or nilary.slice!(start, length) â new_ary or nilary.slice!(range) â new_ary or nil Instance Public methods Deletes the element(s) given by an index (optionally up to length elements) or by a range. Returns the deleted object (or objects), or nil if the index is out of range. a = [ "a", "b", "c" ] a.slice!(1) #=> "b" a #=> ["a", "c"] a.slice!(-1) #=> "c" a #=> ["a"] a.slice!(100) #=> nil a

slice

ary.slice(index) â obj or nilary.slice(start, length) â new_ary or nilary.slice(range) â new_ary or nil Instance Public methods Element Reference â Returns the element at index, or returns a subarray starting at the start index and continuing for length elements, or returns a subarray specified by range of indices. Negative indices count backward from the end of the array (-1 is the last element). For start and range cases the starting index is just before a

size

size() Instance Public methods Alias for: length