Actions
Feature #15076
closedStruct to raise error when keyword arguments used but not enabled
Status:
Rejected
Assignee:
-
Target version:
-
Description
When Struct is used to instantiate object with keyword arguments disabled and yet if instantiated using keyword arguments, the instance fields will be set incorrectly.
Will it be clearer if a error is raised instead rather than assigning data incorrectly ? This is helpful and save time in nailing such issue in a large code base when there is mixture of Struct define with and without keyword arguments.
For example,
Info = Struct.new(:name, :country) # without keyword argument enabled
c = Info.new(name: "myname", country: "Japan") # Instantiate with keywords
The c.name contains hash, and c.country is nil
Actions
Like0
Like0Like0Like0