Paul Butcher wrote:
> I was unable to find any such documentation, so I decided to have a go
> myself :-) You can see the fruits of my labours here:
> 
> http://www.texperts.com/2007/10/16/navigating-the-equality-maze/

Nobody has (yet) risen to the challenge at the end of my article, so I 
thought that I'd ask here :-)

Just about every class in the standard library implements == and eql? as 
I describe in the article, i.e. eql? tests for equal values and == tests 
for "natural" equality (which normally means equal values).

For example:

    [1, 2].eql? [1,2]
    => true
    'foo'.eql? 'foo'
    => true
    [1, 2] == [1,2]
    => true
    'foo' == 'foo'
    => true

Hash, however, is an exception. Hash#== tests for equal values. 
Hash.eql?, however, tests for object identity:

    {:x=>1, :y=>2} == {:x=>1, :y=>2}
    => true
    {:x=>1, :y=>2}.eql?({:x=>1, :y=>2})
    => false

Why is hash the odd one out? I'm sure that there must be a good reason 
(Matz?) but I can't at the moment work out what it might be.

I'd be very grateful for any light anyone could cast on this. Thanks!

Paul.
-- 
Posted via http://www.ruby-forum.com/.