Issue #21921 has been updated by mame (Yusuke Endoh). The current specification of `Hash#<=` is to check if all elements of the supposedly smaller Hash are included in the supposedly larger Hash. I think the reported behaviors are actually working as specified. https://github.com/ruby/ruby/blob/master/doc/language/hash_inclusion.rdoc Did this behavior cause any issues in a real-world application? If you just noticed the inconsistency, I think it's fine to keep the status quo. If we really must fix it, raising an exception when comparing a `compare_by_identity` Hash with a normal Hash via `<=` or `>=` (leaving `Hash#==` as is) seems reasonable. ---------------------------------------- Bug #21921: Hash inconsistent ==, >=, <= behavior https://bugs.ruby-lang.org/issues/21921#change-116512 * Author: cohen (Cohen Carlisle) * Status: Open * ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Hash seems to have very inconsistent behavior for `==`, `>=`, and `<=`. Given that below h1 == h2 is `false` and that they have the same number of keys, I would expect `<=` and `>=` to also be `false`. However, surprisingly `h1 <= h2` and `h2 >= h1` are `true`, while all other permutations are `false`. ``` h1 = {}.compare_by_identity.tap { _1["one"] = 1 } # => {"one" => 1} h2 = {"one" => 1} # => {"one" => 1} h1 == h2 # => false h2 == h1 # => false h1 >= h2 # => false h1 <= h2 # => true h2 >= h1 # => true h2 <= h1 # => false ``` -- https://bugs.ruby-lang.org/