From: Robert Dober Date: 2010-05-14T20:01:34+09:00 Subject: Re: Comparing elements within an array On Fri, May 14, 2010 at 12:47 PM, Toby Rodwell wrote: ah a #unique_by, I therefore conclude that you want to keep one element with the given property. module Enumerable def unique_by &blk keys = {} reject{ | ele | key = blk[ele] keys[key].tap{ keys[key]=true } } end end p [*1..10].unique_by{ |x| x % 3 } Could'nt come up with something more concise :( HTH R. -- The best way to predict the future is to invent it. -- Alan Kay