From: Akinori MUSHA Date: 2002-09-04T13:01:38+09:00 Subject: Re: Set.rb patch At Wed, 4 Sep 2002 12:44:40 +0900, I wrote: > This is not eql?() is expected to be. The only requirement to eql?() > is make (a == b => a.eql?(b)) always true; in other words, guarantee > (!a.eql?(b) => a != b). See how Hash compares keys: PTR_NOT_EQUAL() > in st.c. D'oh, I was confused. I meant (a.hash == b.hash => a.eql?(b)) i.e. (!a.eql?(b) => a.hash != b.hash). And the following test is an irrelevant requirement anyway: > > + def test_eql? > > + a = EqlClass.new > > + b = EqlClass.new until b.hash == a.hash > > + assert !(Set[a].eql?(Set[b])) > > + end I think x.eql?(y) does not need to be false for any given x and y. It is certainly not preferable but the following definition of a class is possible and legal: class Foo def hash 1 end def eql?() true end end Am I missing something? -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "When I leave I don't know what I'm hoping to find When I leave I don't know what I'm leaving behind.."