Issue #21858 has been updated by Dan0042 (Daniel DeLorme).
```ruby Hash(obj) #=> current: can't convert S into Hash (TypeError) #=> proposal: {a: 1, b: 2} ```
This is not really a behavior **change** but more like a backward-compatible behavior **addition/extension** It's really in the same vein as adding a method: ```ruby {a:1,b:2}.except(:b) #Ruby 2.7: undefined method `except' for {:a=>1, :b=>2}:Hash (NoMethodError) #Ruby 3.0: {:a=>1} ``` Or adding an optional parameter: ```ruby %w[a b a c].tally({}) #Ruby 3.0: wrong number of arguments (given 1, expected 0) (ArgumentError) #Ruby 3.1 => {"a" => 2, "b" => 1, "c" => 1} ``` Neither of these can really be considered a "behavior change" ---------------------------------------- Feature #21858: `Kernel#Hash` considers `to_h` too https://bugs.ruby-lang.org/issues/21858#change-116434 * Author: ccmywish (Aoran Zeng) * Status: Open ---------------------------------------- 1. `Kernel#Integer` uses `to_int` first and `to_i` second 2. `Kernel#Array` uses `to_ary` first and `to_a` second 3. `Kernel#Hash` only uses `to_hash` I don't quite understand why there is a need for differential treatment here. I admit that maybe the only benefit of considering `to_h` secondly is that it enables multiple APIs to maintain consistency. -- https://bugs.ruby-lang.org/