==(p1)
public
Equality—At the Object level,
== returns true only if obj and other
are the same object. Typically, this method is overridden in descendent classes
to provide class-specific meaning.
Unlike ==, the equal?
method should never be overridden by
subclasses: it is used to determine object identity (that is,
a.equal?(b) iff a is the same object as b).
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
1.eql? 1.0
Show source
/*
* call-seq:
* obj == other => true or false
* obj.equal?(other) => true or false
* obj.eql?(other) => true or false
*
* Equality---At the <code>Object</code> level, <code>==</code> returns
* <code>true</code> only if <i>obj</i> and <i>other</i> are the
* same object. Typically, this method is overridden in descendent
* classes to provide class-specific meaning.
*
* Unlike <code>==</code>, the <code>equal?</code> method should never be
* overridden by subclasses: it is used to determine object identity
* (that is, <code>a.equal?(b)</code> iff <code>a</code> is the same
* object as <code>b</code>).
*
* The <code>eql?</code> method returns <code>true</code> if
<i>obj</i> and <i>anObject</i> have the
* same value. Used by <code>Hash</code> to test members for equality.
* For objects of class <code>Object</code>, <code>eql?</code> is
* synonymous with <code>==</code>. Subclasses normally continue this
* tradition, but there are exceptions. <code>Numeric</code> types, for
* example, perform type conversion across <code>==</code>, but not
* across <code>eql?</code>, so:
*
* 1 == 1.0
* 1.eql? 1.0
*/
static VALUE
rb_obj_equal(obj1, obj2)
VALUE obj1, obj2;
{
if (obj1 == obj2) return Qtrue;
return Qfalse;
}