From: dblack@... Date: 2007-08-09T20:53:24+09:00 Subject: Re: Collect objects from an array based on one unique parame Hi -- On Thu, 9 Aug 2007, Robert Klemme wrote: > # 2. alternative impl. > selection.things. I think you mean selection = things :-) > inject({}) do |h,th| > h[th.name] = h.has_key? th.name ? nil : th When I tried your code I found you need parens: h[th.name] = h.has_key?(th.name) ? nil : th Otherwise it's like: h[th.name] = h.has_key? (th.name ? nil : th) and you get [false, false, false, ...]. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)