You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While (1.) & (2.) are documented on http://ruby-doc.org/core-2.2.2/Hash.html and (3.) & (4.) follow from (1.) when plugging in the alternate Symbol literal notations, (5.) & (6.) seem to be undocumented yet.
The text was updated successfully, but these errors were encountered:
In Ruby >= 2.2, the following Hash literals are equivalent:
{ :my_key => 5 }
(Symbol literal used as key in the generic hash literal notation that'd work for non-Symbol keys, too.)
{ my_key: 5 }
(Symbol-key-specific "JavaScript-like" new notation introduced in Ruby 1.9)
{ :"my_key" => 5 }
(Same as (1.), just with a different notation for the Symbol literal. Allows string interpolation inside the symbol name.)
{ :'my_key' => 5 }
(Same as (1.), just with a different notation for the Symbol literal. No string interpolation.)
{ "my_key": 5 }
(Introduced by feature request #4276 in Ruby 2.2. Allows string interpolation inside the symbol name.)
{ 'my_key': 5 }
(Probably also introduced by feature request Move rb_int_coerce ruby/ruby#4276. No string interpolation.)
While (1.) & (2.) are documented on http://ruby-doc.org/core-2.2.2/Hash.html and (3.) & (4.) follow from (1.) when plugging in the alternate Symbol literal notations, (5.) & (6.) seem to be undocumented yet.
The text was updated successfully, but these errors were encountered: