From: Christoph Rippel Date: 2001-03-20T09:39:43+09:00 Subject: [ruby-talk:12894] Hash-Hash - behavior clarification? Hi, I have been investigating and using Hash-Hashes and their behavior completely defied my understanding of them. Quote from Dave's and Andy's book .. `` 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 As a consequence it's impossible to form Hash-Hashes - for example (Ruby syntax rules do allow something like {{1=> 1} => {1 =>1}} ) e = {}; h = {} p ({ e => 1 } == {f => 1}) # => false This would be easy to fix with something like (un-efficient and recursion unprotected - note the internal Hash implementation ignores this ``corrected'' hash #method.) class Hash def hash res = 0 each do |l,r| res = (l.hash<<1) + r.hash + 1 end res end end My guess is that this was not done on purpose but figured I ask anyway if the semantically incorrect #hash Hash method is here to stay? Christoph