"ts" <decoux / moulon.inra.fr> schrieb im Newsbeitrag
news:200501271033.j0RAXMu05608 / moulon.inra.fr...
> >>>>> "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?

Hm...

class Dummy
  def eql?(x) puts "eql?"; super end
  def equal?(x) puts "equal?"; super end
  def ==(x) puts "=="; super end
  def hash() puts "hash"; super end
  def id() puts "id"; super end
end

>> h={Dummy.new => 1, Dummy.new =>2}
hash
hash
=> {#<Dummy:0x10187428>=>2, #<Dummy:0x10187440>=>1}
>> h.keys.concat(h.keys).uniq
hash
hash
hash
hash
hash
hash
hash
hash
=> [#<Dummy:0x10187428>, #<Dummy:0x10187440>]

I don't see eql? called here - maybe it's an internal optimization that
short circuits identity.  Or did I miss something?

Kind regards

    robert