ActionsLike0
Feature #9047
closedAlternate hash key syntax for symbols
Description
=begin
In Ruby, if you can create a symbol with ((|:"symbolname"|)), it seems consistent to allow moving the colon to the right side in a hash and dropping the hash rocket (=>).
{
:str => "v", # symbol
str: "v", # symbol
:"str" => "v", # symbol
"str": "v", # should also be a symbol
}
It would look like this:
h = {
"mykey": "value",
"otherkey": "othervalue",
regular_symbol: "value"
}
String and other non-symbol keys would retain the hash rocket syntax to avoid ambiguity.
{
"string" => "v",
MyObj.new => "v",
@my_var => "v"
}
Thoughts?
=end
Updated by matz (Yukihiro Matsumoto) over 11 years ago
- Assignee set to matz (Yukihiro Matsumoto)
- Target version set to 2.6
Updated by nobu (Nobuyoshi Nakada) about 11 years ago
- Is duplicate of Feature #4276: Allow use of quotes in symbol syntactic sugar for hashes added
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Status changed from Open to Closed
ActionsLike0