I donβt know the arguments for this particular choice in ruby, but Iβll just point out that equality is a complex concept.
Common Lisp, for example, has eq, eql, equal, equalp and for this question =
It is very useful to be able to distinguish between two references to the same object, two different objects of the same type with the same value, two objects with the same value, but different types, etc. How many variations make sense depends on what makes sense in the language.
If I remember it correctly (I don't use ruby), rubys predicates implement three of these cases
== is the equality of value
EQL? is the equality of value and type
are equal? true only for the same object
simon source
share