==

ary == other_ary â bool Instance Public methods Equality â Two arrays are equal if they contain the same number of elements and if each element is equal to (according to Object#==) the corresponding element in other_ary. [ "a", "c" ] == [ "a", "c", 7 ] #=> false [ "a", "c", 7 ] == [ "a", "c", 7 ] #=> true [ "a", "c", 7 ] == [ "a", "d", "f" ] #=> false

[] 2

ary[index] â obj or nilary[start, length] â new_ary or nilary[range] â new_ary or nilary.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 co

[]=

ary[index] = obj â objary[start, length] = obj or other_ary or nil â obj or other_ary or nilary[range] = obj or other_ary or nil â obj or other_ary or nil Instance Public methods Element Assignment â Sets the element at index, or replaces a subarray from the start index for length elements, or replaces a subarray specified by the range of indices. If indices are greater than the current capacity of the array, the array grows automatically.

abbrev

abbrev(pattern = nil) Instance Public methods Calculates the set of unambiguous abbreviations for the strings in self. require 'abbrev' %w{ car cone }.abbrev #=> {"ca" => "car", "con"=>"cone", "co" => "cone", "car"=>"car", "cone" => "cone"} The optional pattern parameter is a pattern or a string. Only input strings that match the pattern or start with the string are included in the output hash. %w{ fast boat day }.abbrev(/^.a/) #=> {"fas"=>"fast", "fa"=

assoc

ary.assoc(obj) â new_ary or nil Instance Public methods Searches through an array whose elements are also arrays comparing obj with the first element of each contained array using obj.==. Returns the first contained array that matches (that is, the first associated array), or nil if no match is found. See also #rassoc s1 = [ "colors", "red", "blue", "green" ] s2 = [ "letters", "a", "b", "c" ] s3 = "foo" a = [ s1, s2, s3 ] a.assoc("letters") #=> [ "letters", "a", "b", "c"

at

ary.at(index) â obj or nil Instance Public methods Returns the element at index. A negative index counts from the end of self. Returns nil if the index is out of range. See also #[]. a = [ "a", "b", "c", "d", "e" ] a.at(0) #=> "a" a.at(-1) #=> "e"

bsearch

ary.bsearch {|x| block } â elem Instance Public methods By using binary search, finds a value from this array which meets the given condition in O(log n) where n is the size of the array. You can use this method in two use cases: a find-minimum mode and a find-any mode. In either case, the elements of the array must be monotone (or sorted) with respect to the block. In find-minimum mode (this is a good choice for typical use case), the block must return true or false, and there

clear

ary.clear â ary Instance Public methods Removes all elements from self. a = [ "a", "b", "c", "d", "e" ] a.clear #=> [ ]

collect

ary.collect { |item| block } â new_aryary.collect â Enumerator Instance Public methods Invokes the given block once for each element of self. Creates a new array containing the values returned by the block. See also Enumerable#collect. If no block is given, an Enumerator is returned instead. a = [ "a", "b", "c", "d" ] a.map { |x| x + "!" } #=> ["a!", "b!", "c!", "d!"] a #=> ["a", "b", "c", "d"]

collect!

ary.collect! {|item| block } â aryary.collect! â Enumerator Instance Public methods Invokes the given block once for each element of self, replacing the element with the value returned by the block. See also Enumerable#collect. If no block is given, an Enumerator is returned instead. a = [ "a", "b", "c", "d" ] a.map! {|x| x + "!" } a #=> [ "a!", "b!", "c!", "d!" ]