From: Robert Dober Date: 2010-05-14T23:39:25+09:00 Subject: Re: Comparing elements within an array On Fri, May 14, 2010 at 4:19 PM, alexg wrote: > On Fri, 14 May 2010 22:03:21 +0900, Toby Rodwell wrote: yes I do not worry about 1.8 much anymore, not very considerate of me though, sorry > The code is ruby 1.9 only I think. Another way for 1.8.6: > > module Enumerable >  def unique_by &blk >    keys = {} >    find_all{ | ele | >      key = blk[ele] >      keys.has_key?(key) ? false : keys[key] = true which is better than tap anyway :) R. -- The best way to predict the future is to invent it. -- Alan Kay