Reputation: 8845
Is it possible to make ruby raise an error on a duplicate key definition in a hash. E.g.
{a: 1, b: 2, a: 3}
Currently this just gives a warning like so:
warning: key :a is duplicated and overwritten on line 1
I would rather get an exception
BTW: I'm on ruby 2.7
Upvotes: 0
Views: 311
Reputation: 8646
This is a parse timew warning. I don't think you can generate an exception: https://github.com/ruby/ruby/blob/master/parse.y#L12201
Upvotes: 1