Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Hash#eql?
(untyped object) -> bool
eql?(object) → true or false
hash.c
View on GitHub ↗
static VALUE
rb_hash_eql(VALUE hash1, VALUE hash2)
{
return hash_equal(hash1, hash2, TRUE);
}
Returns true if all of the following are true:
-
The given
objectis aHashobject. -
selfandobjecthave the same keys (regardless of order). -
For each key
key,self[key].eql?(object[key]).
Otherwise, returns false.
Example
h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1, baz: 2} h1.eql? h2 # => true h3 = {baz: 2, bar: 1, foo: 0} h1.eql? h3 # => true
Related: see Methods for Querying.