From: Sean O'Halpin Date: 2007-10-28T23:02:16+09:00 Subject: Re: Duplicate elements in array ------=_Part_9216_2267369.1193580138481 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/28/07, Robert Klemme wrote: > > irb(main):007:0> array = %w{apple banana apple orange} > => ["apple", "banana", "apple", "orange"] > irb(main):008:0> array.inject(Hash.new(0)) {|ha,e| > ha[e]+=1;ha}.delete_if {|k,v| v==1}.keys > => ["apple"] > > Kind regards > > robert > > Succint ~and~ efficient! Do you have a mail filter checking for any posts containing 'inject'? :) Regards, Sean ------=_Part_9216_2267369.1193580138481--