itsme213 <itsme213 / hotmail.com> wrote: > "Martin DeMello" <martindemello / yahoo.com> wrote in message > > > A uniq_by would probably cover > > most of the use cases anyway. > > Why a different method? Is that the way it is done elsewhere? Why not > def uniq > if block_given? > ... less_efficient > else default_way > end By analogy with sort and sort_by a.uniq_by {|i| i[1]} would work like uniq, but hashing i[i] rather than i. a.uniq {|i,j| f(i,j) == true } would be the generalised method, but as noted that's O(n^2) rather than O(n). (Also I'm not sure it'd be algorithmically sound - you could introduce order dependencies with a sufficiently adversarial comparison function.) martin