Project

General

Profile

Feature #9686

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

Symbols are often used literally as keys in hashes like this:

~~~ruby
{foo: 'bar'}
~~~
`{foo: 'bar'}`

But acutally there is a little inconvenience when using the alternative `:"name"` :"name" literal syntax:

~~~ruby
string
`string = 'foo'
{:"#{string}" => 'bar'}
~~~
'bar'}`

It would be great if Ruby provided the possibility to write the second example like this:

~~~ruby
string
`string = 'foo'
{"#{string}": 'bar'}
~~~
'bar'}`

This would be logical, because you can write both syntaxes the same way when not using them in hashes.

Back