Issue #9047 has been updated by Nobuyoshi Nakada.

Status changed from Open to Closed

Applied in changeset r47649.

----------
parse.y: quoted ID key

* parse.y (assoc): allow quoted ID as a key of a hash literal.
  [ruby-core:34453] [Feature #4276]

----------------------------------------
Feature #9047: Alternate hash key syntax for symbols
https://bugs.ruby-lang.org/issues/9047#change-48990

* Author: Jamon Holmgren
* Status: Closed
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: 
* Target version: next minor
----------------------------------------
=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



-- 
https://bugs.ruby-lang.org/