ary.uniq â new_ary
ary.uniq { |item| ... } â new_ary
ary.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"], ["teacher", "matz"]]
Please login to continue.