method

uniq

Importance_1
Ruby latest stable (v1_8_7_72) - 1 note - Class: Array
uniq() public

Returns a new array by removing duplicate values in self.

   a = [ "a", "a", "b", "b", "c" ]
   a.uniq   #=> ["a", "b", "c"]
Show source
Register or log in to add new notes.
January 25, 2010
1 thank

custom uniq method

Build hash from elements of your Array using attribute as key and the element as value and return values of Hash:

 Hash[*ary.map {|obj| [obj.name, obj]}.flatten].values