Issue #9047 has been updated by jamonholmgren (Jamon Holmgren).


@matz -- sorry, I didn't receive an email notification, so I didn't realize you had responded.

This isn't MRI, I realize, but in RubyMotion this notation would come in handy.

https://github.com/clearsightstudio/ProMotion/issues/345#issuecomment-29115788

    add UIButton.new, {
      "setTitle:forState:" => ['Register', UIControlStateNormal],
      "addTarget:action:forControlEvents" => [self, 'register', UIControlEventTouchUpInside]
    }
    
    # becomes:
    
    add UIButton.new, {
      "setTitle:forState:": ['Register', UIControlStateNormal],
      "addTarget:action:forControlEvents" => [self, 'register', UIControlEventTouchUpInside]
    }

Another situation is when you want to map strings:

    def map_string(source_string)
      {
        "jamon-holmgren": "Jamon A. Holmgren",
        "matzumoto-yukihiro": "Yukihiro Matsumoto"
      }[source_string]
    end

Perhaps somewhat contrived, but you get the point. The first (RubyMotion) example I do deal with on a regular basis, being the creator of ProMotion.


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

Author: jamonholmgren (Jamon Holmgren)
Status: Open
Priority: Normal
Assignee: matz (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


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