On 10/16/07, Paul Butcher <paul / texperts.com> wrote:
> I recently found myself explaining to a friend how Ruby's various
> comparison operators work. In the process, I tried to find some decent
> documentation on why Ruby has so many different ways to test for
> equality, how they differ and how they should be implemented and used.
>
> 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/
>
> I believe that it's an accurate reflection of both how things work and
> the philosophy underlying the design of this area. I would be very
> grateful if you could let me know if I have anything wrong or have left
> anything out though!
>
> There are a number of subtle pitfalls in this area waiting to trap the
> unwary. I hope that this may go some way to helping a few people avoid
> them :-)
>
> Comments, criticisms and suggestions all gratefully received.

Thanks for this. I found it great for a quick reference and to explain
it to someone else :-).

There are a couple of typos that you might want to correct:

Note that this means that, unlike the other methods we're considering
here, this means that === won't in general be commutative:

String === 'foo'
=> true
'foo' == String
=> false


Should be 'foo' === String (three equals).

[...]
In the vast majority of cases, you will either want to test for
"natural" equality (===)

Should be (==).

Thanks,

Jesus.