Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns true if both array.size == other_array.size and for each index i in array, array[i] == other_array[i]:
a0 = [:foo, 'bar', 2]
a1 = [:foo, 'bar', 2.0]
a1 == a0 # => true
[] == [] # => true
Otherwise, returns false.
This method is different from method Array#eql?, which compares elements using Object#eql?.
               static VALUE
rb_ary_equal(VALUE ary1, VALUE ary2)
    if (ary1 == ary2) return Qtrue;
    if (!RB_TYPE_P(ary2, T_ARRAY)) {
        if (!rb_respond_to(ary2, idTo_ary)) {
            return Qfalse;
        return rb_equal(ary2, ary1);
    if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
    return rb_exec_recursive_paired(recursive_equal, ary1, ary2, ary2);

Was this page useful?