Problem
==
===
eql?
equal?
==
– Checks if the value of two operands are equal (often overridden to provide a class-specific definition of equality).===
– Specifically used to test equality within thewhen
clause of acase
statement (also often overridden to provide meaningful class-specific semantics in case statements).eql?
– Checks if the value and type of two operands are the same (as opposed to the==
operator which compares values but ignores types). For example,1 == 1.0
evaluates totrue
, whereas1.eql?(1.0)
evaluates tofalse
.equal?
– Compares theidentity
of two objects; i.e., returnstrue
iff both operands have the same object id (i.e., if they both refer to the same object). Note that this will returnfalse
when comparing two identical copies of the same object.