Issue #9047 has been updated by mohawkjohn (John Woods).


=begin
This may or may not be related, but we here at NMatrix (part of SciRuby) would love to be able to index ranges in NMatrix using a 1:3 notation. This can be accomplished with a hash, but only if it will allow numeric (rather than symbolic keys) before the colon. Currently we have to type:

(({n[1=>3, 2=>4]}))

or use the .../.. notation, but we would prefer

(({n[1:3,2:4]}))
=end

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

Author: jamonholmgren (Jamon Holmgren)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


=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


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