From: "solnic (Peter Solnica) via ruby-core" Date: 2022-12-25T13:09:16+00:00 Subject: [ruby-core:111422] [Ruby master Bug#19257] Data that defines a member called hash Issue #19257 has been reported by solnic (Peter Solnica). ---------------------------------------- Bug #19257: Data that defines a member called hash https://bugs.ruby-lang.org/issues/19257 * Author: solnic (Peter Solnica) * Status: Open * Priority: Normal * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-darwin22] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- I believe this should raise an error given that `Data#hash` exists as a pre-defined core method and serves a very specific purpose: ``` ruby data = Data.define(:hash) obj = data.new(hash: "foo") obj.hash # => "foo" ``` An alternative would be to make `obj[:hash]` return the value of the member and `obj.hash` would return the hash of the object, but that could be confusing. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/