"Martin DeMello" <martindemello / yahoo.com> wrote in message
news:rZ3Kd.187524$6l.10402 / pd7tw2no...
> ts <decoux / moulon.inra.fr> wrote:
> > >>>>> "i" == itsme213  <itsme213 / hotmail.com> writes:
> >
> > i> I agree, #uniq is certainly not the only candidate. I think it would
be very
> > i> useful to compile a list of all such methods that could use a block
to
> > i> override some default internal method (#== in the case of uniq), and
> > i> consider these for 2.0.
> >
> >  #uniq don't use #==, it use #hash and #eql?
>
> Which raises the problem that it works globally, unlike the unix uniq
> which only uniqs consecutive elements. Passing in a block would lead to
> a performance hit since you'd need to compare every pair of elements
> without the benefit of a hash function.

Good points. Probably applies to many other cases that I was thinking 'Now,
why is there no block here?'

> 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