Skip to content

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

instance method

Array#hash

array.hash → integer

Returns the integer hash value for self.

Two arrays with the same content will have the same hash code (and will compare using eql?):

Example
[0, 1, 2].hash == [0, 1, 2].hash # => true
[0, 1, 2].hash == [0, 1, 3].hash # => false
See also #flatten! #include? #flatten #index also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1