From: Rick DeNatale Date: 2006-09-21T09:34:17+09:00 Subject: Re: Bug in Hash#hash? (Ruby 1.8.4) On 9/20/06, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Bug in Hash#hash? (Ruby 1.8.4)" > on Wed, 20 Sep 2006 23:40:11 +0900, "Eyal Oren" writes: > > |say one = {:a=>:b} > |then one.hash != one.clone.hash > |is that a bug or correct? > | > |(using ruby 1.8.4 (2005-12-24) [i486-linux]) > > Currently it's an intended behavior. Hash is not designed to be hash > key (two hashes are considered to be a same key if they are exactly > the same object). It's not likely to change in 1.8 series. In 1.9, > maybe. And I think more precisely, it's that hash needs to be implemented so that a.eql?(b) implies a.hash == b.hash one = {:a => :b} two = one.clone one == two #=> true one.eql?(two) #=> false Smalltalkers might recall that Smalltalk has both a Hash which uses Smalltalks equivalents to Ruby's hash and ==, and IdentityHash which uses Smalltalks equivalents to Ruby's object_id for the hash, and equal? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ IPMS/USA Region 12 Coordinator http://ipmsr12.denhaven2.com/ Visit the Project Mercury Wiki Site http://www.mercuryspacecraft.com/