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

Hash#<=

hash <= other_hash → true or false

Returns true if hash is a subset of other_hash, false otherwise:

Example
h1 = {foo: 0, bar: 1}
h2 = {foo: 0, bar: 1, baz: 2}
h1 <= h2 # => true
h2 <= h1 # => false
h1 <= h1 # => true
See also #< #== .try_convert #> also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0