Issue #21858 has been updated by mame (Yusuke Endoh). During the dev meeting discussion, @ko1, not @Dan0042, pointed out the following behavior change. It seems Matz got confused about that. ```ruby S = Struct.new(:a, :b) obj = S.new(1, 2) Hash(obj) #=> current: can't convert S into Hash (TypeError) #=> proposal: {a: 1, b: 2} ``` The behavior changes for objects that only define `to_h`. I'm not sure if this is a "big side effect", but the type coversion methods like `Kernel#Integer` are in principle strict (though this design isn't always strictly enforced), and it may raise an exception for weird input (e.g., `Integer("0x1x")` raises an exception). Therefore, there might be code that expects `Hash(struct)` to raise an exception. ---------------------------------------- Feature #21858: `Kernel#Hash` considers `to_h` too https://bugs.ruby-lang.org/issues/21858#change-116424 * 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/