inconsistent odd-length array rejection in Hash[*ary] vs Hash[ary]
Hash[*ary] raises an error when given odd number of arguments:
In contrast, Hash[ary] silently accepts odd-length arrays:
I think this behavior is inconsistent. Please either:
(1) change Hash[ary] to raise errors upon seeing odd-length arrays or
(2) change Hash[*ary] to not raise an error for odd number of arguments and instead accept the last odd argument as a key with value nil, just like this existing behavior:
Thanks for your consideration.
#3 Updated by nobu (Nobuyoshi Nakada) almost 5 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r36391.
Suraj, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
hash.c: raise on invalid input
- hash.c (rb_hash_s_create): raise an exception, when input elements are not one or two elements arrays. [Bug #5406]