From: "Molitor, Stephen L" Date: 2006-06-27T00:41:01+09:00 Subject: Re: Ruby and Java equality usage On Jun 26, 2006 Matthew Smillie wrote: > Coming from C, I tend to think of Ruby variables as pointers to values, > so I tend to think of the difference between eql? and == as akin to the > following: > Ruby eql? - i.e., are they at the same spot in memory? > int* a; int* b; > a == b; > Ruby == - i.e., do they contain the same value? > int* a; int* b; > *a == *b; The equals? method checks identity. As it says here, http://www.ruby-doc.org/core/classes/Object.html#M001416, the eql? method can be and usually is overridden to be synonymous with ==. If you put your objects in a hash you're going to want to override hash and eql? to have equivalent semantics. Having three separate equality methods leads to this kind of confusion. You need two (identity and value equality) but not 3 IHMO. Steve