Project

General

Profile

Actions

Feature #9686

open

Syntax for symbols used in hashes

Added by saschamayr (Sascha Mayr) about 10 years ago. Updated over 2 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:61743]

Description

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

{foo: 'bar'}

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

string = 'foo'
{:"#{string}" => 'bar'}

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

string = 'foo'
{"#{string}": 'bar'}

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0