From: nobu@... Date: 2016-01-27T02:56:36+00:00 Subject: [ruby-core:73512] [Ruby trunk - Bug #12027] [Rejected] Hash descendants are ignoring custom to_hash method Issue #12027 has been updated by Nobuyoshi Nakada. Description updated Status changed from Open to Rejected Because `b.is_a?(Hash)` already. `to_hash` is the method to pretend to be a `Hash`. ---------------------------------------- Bug #12027: Hash descendants are ignoring custom to_hash method https://bugs.ruby-lang.org/issues/12027#change-56728 * Author: Victor Shepelev * Status: Rejected * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- I'm not sure it is not intended, but feels really strange: ~~~ruby class A def to_hash {foo: 'bar'} end end class B < Hash def to_hash {foo: 'bar'} end end a = A.new b = B.new p({**a}) # => {foo: 'bar'} p({**b}) # => {} -- ooops. Seems "internal" hash state is used # therefore: b['test'] = 1 p({**b}) # => wrong argument type String (expected Symbol) (TypeError) ~~~ What am I missing here? -- https://bugs.ruby-lang.org/ Unsubscribe: