product

ary.product(other_ary, ...) â new_aryary.product(other_ary, ...) { |p| block } â ary Instance Public methods Returns an array of all combinations of elements from all arrays. The length of the returned array is the product of the length of self and the argument arrays. If given a block, product will yield all combinations and return self instead. [1,2,3].product([4,5]) #=> [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]] [1,2].product([1,2]) #=> [[1,1],[1,2],[

pretty_print_cycle

pretty_print_cycle(q) Instance Public methods

pretty_print

pretty_print(q) Instance Public methods

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

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

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

old_to_s

old_to_s() Instance Public methods Alias for: to_s

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

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

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