instance method
Hash#==
(untyped other) -> bool
self == object → true or false
hash.c
View on GitHub ↗
static VALUE
rb_hash_equal(VALUE hash1, VALUE hash2)
{
return hash_equal(hash1, hash2, FALSE);
}
Returns whether self and object are equal.
Returns true if all of the following are true:
-
objectis aHashobject (or can be converted to one). -
selfandobjecthave the same keys (regardless of order). -
For each key
key,self[key] == object[key].
Otherwise, returns false.
Examples:
Example
h = {foo: 0, bar: 1} h == {foo: 0, bar: 1} # => true # Equal entries (same order) h == {bar: 1, foo: 0} # => true # Equal entries (different order). h == 1 # => false # Object not a hash. h == {} # => false # Different number of entries. h == {foo: 0, bar: 1} # => false # Different key. h == {foo: 0, bar: 1} # => false # Different value.
Related: see Methods for Comparing.