Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Array#==

array == other_array → true or false

Returns true if both array.size == other_array.size and for each index i in array, array[i] == other_array[i]:

Example
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?.

See also #<=> #[] #<< #[]= also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0