From: Christoph Rippel Date: 2001-03-20T13:34:41+09:00 Subject: [ruby-talk:12908] Re: Hash-Hash - behavior clarification? > From: dave@thomases.com [mailto:dave@thomases.com]On Behalf Of Dave [...] > > `` Generates a Fixnum hash value for this object. This function must > > have the property that a.eql?(b) implies a.hash == b.hash.... The > > hash value is used by class Hash. ...'' > > > > I finial realized that the #hash method of the Hash class it-self > > violates this behavior it is simply id-based ... > > > > h.hash == h.id # => true for any Hash object > > While I agree that this may be unfortunate, in what way does having > h.hash defined as h.id violate the rules? (If our statement is wrong > I'd like to fix it). It violates the rules because of a = {}; b = {}; p a.eql? b # => true , but p a.hash == b.hash # => false Pointing out that the Hash Class itself is a notable exception from this rule is probably enough - my guess is that Matz did not want to bother implementing a ``correct'' hashing scheme because of efficiency reasons. Christoph [...]