Actions
Feature #12352
closedNew hash syntax broken for numeric keys
Description
[Matz himself showed in RubyConf 2015 the following example]:
h = { 1: 2, 2: 4, 3: 6 }
Which gives
SyntaxError: unexpected ':', expecting =>
h = { 1: 2, 2: 4, 3: 6 }
^
but which should give identical results to
>> h = { 1 => 2, 2 => 4, 3 => 6 }
=> {1=>2, 2=>4, 3=>6}
Updated by shyouhei (Shyouhei Urabe) over 8 years ago
- Status changed from Open to Assigned
- Assignee set to matz (Yukihiro Matsumoto)
- Tracker changed from Bug to Feature
- Project changed from Ruby master to 14
Matz, do you want numeric keys for new hash syntax?
Updated by matz (Yukihiro Matsumoto) over 8 years ago
Although I admit my mistake, I reject this for consistency.
If I allow this syntax, it had to generate
h = {1: 2}
p h # => {:"1", 2}
and no one want this.
Matz.
Updated by matz (Yukihiro Matsumoto) over 8 years ago
- Status changed from Assigned to Rejected
Updated by hsbt (Hiroshi SHIBATA) almost 3 years ago
- Project changed from 14 to Ruby master
Actions
Like0
Like0Like0Like0Like0