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"]

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"]

length

ary.length â int Instance Public methods Returns the number of elements in self. May be zero. [ 1, 2, 3, 4, 5 ].length #=> 5 [].length #=> 0 size

map

ary.map { |item| block } â new_aryary.map â 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"]

map!

ary.map! {|item| block } â aryary.map! â 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!" ]

old_to_s

old_to_s() Instance Public methods Alias for: to_s

pack

arr.pack ( aTemplateString ) â aBinaryString Instance Public methods Packs the contents of arr into a binary sequence according to the directives in aTemplateString (see the table below) Directives âA,'' âa,'' and âZ'' may be followed by a count, which gives the width of the resulting field. The remaining directives also may take a count, indicating the number of array elements to convert. If the count is an asterisk (â*''), all remaining array elements will be converted. Any of t

permutation

ary.permutation { |p| block } â aryary.permutation â Enumeratorary.permutation(n) { |p| block } â aryary.permutation(n) â Enumerator Instance Public methods When invoked with a block, yield all permutations of length n of the elements of the array, then return the array itself. If n is not specified, yield all permutations of all elements. The implementation makes no guarantees about the order in which the permutations are

pop

ary.pop â obj or nilary.pop(n) â new_ary Instance Public methods Removes the last element from self and returns it, or nil if the array is empty. If a number n is given, returns an array of the last n elements (or less) just like array.slice!(-n, n) does. See also #push for the opposite effect. a = [ "a", "b", "c", "d" ] a.pop #=> "d" a.pop(2) #=> ["b", "c"] a #=> ["a"]

pretty_print

pretty_print(q) Instance Public methods