last

ary.last â obj or nilary.last(n) â new_ary Instance Public methods Returns the last element(s) of self. If the array is empty, the first form returns nil. See also #first for the opposite effect. a = [ "w", "x", "y", "z" ] a.last #=> "z" a.last(2) #=> ["y", "z"]

keep_if

ary.keep_if { |item| block } â aryary.keep_if â Enumerator Instance Public methods Deletes every element of self for which the given block evaluates to false. See also #select! If no block is given, an Enumerator is returned instead. a = %w{ a b c d e f } a.keep_if { |v| v =~ /[aeiou]/ } #=> ["a", "e"]

join

ary.join(separator=$,) â str Instance Public methods Returns a string created by converting each element of the array to a string, separated by the given separator. If the separator is nil, it uses current $,. If both the separator and $, are nil, it uses empty string. [ "a", "b", "c" ].join #=> "abc" [ "a", "b", "c" ].join("-") #=> "a-b-c"

inspect

ary.inspect â stringary.to_s â string Instance Public methods Creates a string representation of self. [ "a", "b", "c" ].to_s #=> "[\"a\", \"b\", \"c\"]" to_s

insert

ary.insert(index, obj...) â ary Instance Public methods Inserts the given values before the element with the given index. Negative indices count backwards from the end of the array, where -1 is the last element. a = %w{ a b c d } a.insert(2, 99) #=> ["a", "b", 99, "c", "d"] a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"]

initialize_copy

ary.replace(other_ary) â ary Instance Public methods Replaces the contents of self with the contents of other_ary, truncating or expanding if necessary. a = [ "a", "b", "c", "d", "e" ] a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"] a #=> ["x", "y", "z"]

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.

include?

ary.include?(object) â true or false Instance Public methods Returns true if the given object is present in self (that is, if any element == object), otherwise returns false. a = [ "a", "b", "c" ] a.include?("b") #=> true a.include?("z") #=> false

hash

ary.hash â fixnum Instance Public methods Compute a hash-code for this array. Two arrays with the same content will have the same hash code (and will compare using eql?).

frozen?

ary.frozen? â true or false Instance Public methods Return true if this array is frozen (or temporarily frozen while being sorted). See also Object#frozen?