Method: Array#eql?
- Defined in:
- array.c
#eql?(other_array) ⇒ Boolean
Returns true
if self
and other_array
are the same size, and if, for each index i
in self
, self[i].eql?(other_array[i])
:
a0 = [:foo, 'bar', 2]
a1 = [:foo, 'bar', 2]
a1.eql?(a0) # => true
Otherwise, returns false
.
This method is different from method Array#==, which compares using method Object#==
.
Related: see Methods for Querying.
5304 5305 5306 5307 5308 5309 5310 5311 5312 |
# File 'array.c', line 5304
static VALUE
rb_ary_eql(VALUE ary1, VALUE ary2)
{
if (ary1 == ary2) return Qtrue;
if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse;
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
}
|