Esad Hajdarevic
10/19/2006 9:51:00 AM
Just Another Victim of the Ambient Morality wrote:
> This got me thinking about the role of the "eql?" method. Why does it
> exist? What is the Ruby rationale behind having two different equality
> methods, namely "==" and "eql?"
> Thank you...
ri Object#eql?
...
The +eql?+ method returns +true+ if _obj_ and _anObject_ have the
same value. Used by +Hash+ to test members for equality. For
objects of class +Object+, +eql?+ is synonymous with +==+.
Subclasses normally continue this tradition, but there are
exceptions. +Numeric+ types, for example, perform type conversion
across +==+, but not across +eql?+, so:
1 == 1.0 #=> true
1.eql? 1.0 #=> false
Greetings,
Esad