reverse_each

ary.reverse_each { |item| block } â aryary.reverse_each â Enumerator Instance Public methods Same as #each, but traverses self in reverse order. a = [ "a", "b", "c" ] a.reverse_each {|x| print x, " " } produces: c b a

reverse!

ary.reverse! â ary Instance Public methods Reverses self in place. a = [ "a", "b", "c" ] a.reverse! #=> ["c", "b", "a"] a #=> ["c", "b", "a"]

reverse

ary.reverse â new_ary Instance Public methods Returns a new array containing self's elements in reverse order. [ "a", "b", "c" ].reverse #=> ["c", "b", "a"] [ 1 ].reverse #=> [1]

replace

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

repeated_permutation

ary.repeated_permutation(n) { |p| block } â aryary.repeated_permutation(n) â Enumerator Instance Public methods When invoked with a block, yield all repeated permutations of length n of the elements of the array, then return the array itself. The implementation makes no guarantees about the order in which the repeated permutations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2] a.repeated_permutation(1).to_a #=> [[1], [2

repeated_combination

ary.repeated_combination(n) { |c| block } â aryary.repeated_combination(n) â Enumerator Instance Public methods When invoked with a block, yields all repeated combinations of length n of elements from the array and then returns the array itself. The implementation makes no guarantees about the order in which the repeated combinations are yielded. If no block is given, an Enumerator is returned instead. Examples: a = [1, 2, 3] a.repeated_combination(1).to_a #=> [[

reject!

ary.reject! { |item| block } â ary or nilary.reject! â Enumerator Instance Public methods Equivalent to #delete_if, deleting elements from self for which the block evaluates to true, but returns nil if no changes were made. The array is changed instantly every time the block is called, not after the iteration is over. See also Enumerable#reject and #delete_if. If no block is given, an Enumerator is returned instead.

reject

ary.reject {|item| block } â new_aryary.reject â Enumerator Instance Public methods Returns a new array containing the items in self for which the given block is not true. See also #delete_if If no block is given, an Enumerator is returned instead.

rassoc

ary.rassoc(obj) â new_ary or nil Instance Public methods Searches through the array whose elements are also arrays. Compares obj with the second element of each contained array using obj.==. Returns the first contained array that matches obj. See also #assoc. a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ] a.rassoc("two") #=> [2, "two"] a.rassoc("four") #=> nil

push

ary.push(obj, ... ) â ary Instance Public methods Append â Pushes the given object(s) on to the end of this array. This expression returns the array itself, so several appends may be chained together. See also #pop for the opposite effect. a = [ "a", "b", "c" ] a.push("d", "e", "f") #=> ["a", "b", "c", "d", "e", "f"] [1, 2, 3,].push(4).push(5) #=> [1, 2, 3, 4, 5]