insert_at_last

insert_at_last(num, str) Instance Public methods

new

new(type, name) Class Public methods

|

ary | other_ary â new_ary Instance Public methods Set Union â Returns a new array by joining ary with other_ary, excluding any duplicates and preserving the order from the original array. It compares elements using their hash and eql? methods for efficiency. [ "a", "b", "c" ] | [ "c", "d", "a" ] #=> [ "a", "b", "c", "d" ] See also #uniq.

zip

ary.zip(arg, ...) â new_aryary.zip(arg, ...) { |arr| block } â nil Instance Public methods Converts any arguments to arrays, then merges elements of self with corresponding elements from each argument. This generates a sequence of ary.size n-element arrays, where n is one more than the count of arguments. If the size of any argument is less than the size of the initial array, nil values are supplied. If a block is given, it is invoked for each output array, other

values_at

ary.values_at(selector, ...) â new_ary Instance Public methods Returns an array containing the elements in self corresponding to the given selector(s). The selectors may be either integer indices or ranges. See also #select. a = %w{ a b c d e f } a.values_at(1, 3, 5) # => ["b", "d", "f"] a.values_at(1, 3, 5, 7) # => ["b", "d", "f", nil] a.values_at(-1, -2, -2, -7) # => ["f", "e", "e", nil] a.values_at(4..6, 3...6) # => ["e", "f", nil, "d", "e", "

unshift

ary.unshift(obj, ...) â ary Instance Public methods Prepends objects to the front of self, moving other elements upwards. See also #shift for the opposite effect. a = [ "b", "c", "d" ] a.unshift("a") #=> ["a", "b", "c", "d"] a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"]

uniq!

ary.uniq! â ary or nilary.uniq! { |item| ... } â ary or nil Instance Public methods Removes duplicate elements from self. If a block is given, it will use the return value of the block for comparison. It compares values using their hash and eql? methods for efficiency. Returns nil if no changes are made (that is, no duplicates are found). a = [ "a", "a", "b", "b", "c" ] a.uniq! # => ["a", "b", "c"] b = [ "a", "b", "c" ] b.uniq! # => nil c = [["student","

uniq

ary.uniq â new_aryary.uniq { |item| ... } â new_ary Instance Public methods Returns a new array by removing duplicate values in self. If a block is given, it will use the return value of the block for comparison. It compares values using their hash and eql? methods for efficiency. a = [ "a", "a", "b", "b", "c" ] a.uniq # => ["a", "b", "c"] b = [["student","sam"], ["student","george"], ["teacher","matz"]] b.uniq { |s| s.first } # => [["student", "sam"], ["te

transpose

ary.transpose â new_ary Instance Public methods Assumes that self is an array of arrays and transposes the rows and columns. a = [[1,2], [3,4], [5,6]] a.transpose #=> [[1, 3, 5], [2, 4, 6]] If the length of the subarrays don't match, an IndexError is raised.

to_s

to_s() Instance Public methods Also aliased as: old_to_s