Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Array#hash
array.hash → integer
array.c
View on GitHub ↗
static VALUE
rb_ary_hash(VALUE ary)
{
return rb_ary_hash_values(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary));
}
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