drop

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

drop_while

ary.drop_while { |arr| block } â new_aryary.drop_while â Enumerator Instance Public methods Drops elements up to, but not including, the first element for which the block returns nil or false and returns an array containing the remaining elements. If no block is given, an Enumerator is returned instead. See also #take_while a = [1, 2, 3, 4, 5, 0] a.drop_while {|i| i < 3 } #=> [3, 4, 5, 0]

each

ary.each { |item| block } â aryary.each â Enumerator Instance Public methods Calls the given block once for each element in self, passing that element as a parameter. An Enumerator is returned if no block is given. a = [ "a", "b", "c" ] a.each {|x| print x, " -- " } produces: a -- b -- c --

each_index

ary.each_index { |index| block } â aryary.each_index â Enumerator Instance Public methods Same as #each, but passes the index of the element instead of the element itself. An Enumerator is returned if no block is given. a = [ "a", "b", "c" ] a.each_index {|x| print x, " -- " } produces: 0 -- 1 -- 2 --

empty?

ary.empty? â true or false Instance Public methods Returns true if self contains no elements. [].empty? #=> true

eql?

ary.eql?(other) â true or false Instance Public methods Returns true if self and other are the same object, or are both arrays with the same content (according to Object#eql?).

fetch

ary.fetch(index) â objary.fetch(index, default) â objary.fetch(index) { |index| block } â obj Instance Public methods Tries to return the element at position index, but throws an IndexError exception if the referenced index lies outside of the array bounds. This error can be prevented by supplying a second argument, which will act as a default value. Alternatively, if a block is given it will only be executed when an invalid index is referenced. Neg

fill

ary.fill(obj) â aryary.fill(obj, start [, length]) â aryary.fill(obj, range ) â aryary.fill { |index| block } â aryary.fill(start [, length] ) { |index| block } â aryary.fill(range) { |index| block } â ary Instance Public methods The first three forms set the selected elements of self (which may be the entire array) to obj. A start of nil is equivalent to zero. A length of nil is e

find_index

ary.index(obj) â int or nilary.index { |item| block } â int or nilary.index â Enumerator Instance Public methods Returns the index of the first object in ary such that the object is == to obj. If a block is given instead of an argument, returns the index of the first object for which the block returns true. Returns nil if no match is found. See also #rindex. An Enumerator is returned if neither a block nor argument is given. a = [ "a", "b", "c" ] a

first

ary.first â obj or nilary.first(n) â new_ary Instance Public methods Returns the first element, or the first n elements, of the array. If the array is empty, the first form returns nil, and the second form returns an empty array. See also #last for the opposite effect. a = [ "q", "r", "s", "t" ] a.first #=> "q" a.first(2) #=> ["q", "r"]