From: Robert Klemme Date: 2005-01-27T20:07:01+09:00 Subject: Re: Array::uniq { block } ? "ts" schrieb im Newsbeitrag news:200501271033.j0RAXMu05608@moulon.inra.fr... > >>>>> "i" == itsme213 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 => {#=>2, #=>1} >> h.keys.concat(h.keys).uniq hash hash hash hash hash hash hash hash => [#, #] 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