Issue #21921 has been updated by Dan0042 (Daniel DeLorme).
An entry `h0[k0]` in one hash is equal to an entry `h1[k1]` in another hash if and only if the two keys are equal (`k0 == k1`) and their two values are equal (`h0[k0] == h1[h1]`).
This sentence is merely defining the phrase "is equal to". It does not describe the hash lookup mechanism itself.
It doesn't just say "equal", it specifically mentions `k0 == k1`; might be worth disambiguating to "if the two keys are equal (either `k0.eql? k1` or `k0.equal? k1`)" But what has me puzzled is the relationship of == vs <= vs < I am fine with the notion that h1 (compare_by_identity) is a strict subset of h2, so `h1==h2 => false` is fine and `h1<=h2 => true` is fine, but in that case it should mean that `h1<h2 => true` but that is not the case. Isn't that a bug? ---------------------------------------- Bug #21921: Hash inconsistent ==, >=, <= behavior https://bugs.ruby-lang.org/issues/21921#change-116525 * 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/