Project

General

Profile

Actions

Bug #19257

closed

Data that defines a member called hash

Added by solnic (Peter Solnica) over 1 year ago. Updated over 1 year ago.

Status:
Feedback
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-darwin22]
[ruby-core:111422]

Description

I believe this should raise an error given that Data#hash exists as a pre-defined core method and serves a very specific purpose:

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0