From: Andrew Walrond Date: 2005-05-05T22:33:29+09:00 Subject: Re: Whats so different about a Hash? On Thursday 05 May 2005 14:19, Adriano Ferreira wrote: > > > irb(main):040:0> a.eql?(b) > > => true > > When I do this, I get: > > irb(main):003:0> {1=>2}.eql?({1=>2}) > => false I've been discussing this on ruby-core aswell. It turns out that this was 'fixed' in then latest stable snapshot. > > For numbers, strings and arrays you will find .hash and .eql? methods > which are consistent, meaning they play fair as hash keys. > > This is not the same with Hash objects. Probably for performance > reasons and because in some ocasions one expects hashes to be equal > only if they are the same objects, .hash and .eql? are not defined > such that hashes are equal if they have the same pairs. I think they > actually inherit Object methods such that > hash1.eql?(hash2) is the same as hash1===hash2 > and > hash1.hash calls Object.hash which is based on object ID > Understood. See my forwarded message... Andrew Walrond