Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
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#==.
 
               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_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue;
    return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
}
            

Was this page useful?