From: Erik Veenstra Date: 2007-03-07T03:56:07+09:00 Subject: Re: remove duplicates of array of object based on a attribute And here's the inevitable one-liner... :} (But I do prefer the group_by version...) gegroet, Erik V. - http://www.erikveen.dds.nl/ ---------------------------------------------------------------- ################################################################ arr = [ {:id => 1, :w => 30}, {:id => 2, :w => 20}, {:id => 3, :w => 10}, {:id => 1, :w => 10}, {:id => 1, :w => 40}, {:id => 2, :w => 50}, {:id => 4, :w => 60}, {:id => 4, :w => 30}, {:id => 2, :w => 20}, {:id => 3, :w => 10} ] ################################################################ res1=arr.inject({}){|h,o|(h[o[:id]]||=[])<