Project

General

Profile

Actions

Feature #4801

closed

Shorthand Hash Syntax for Strings

Added by wardrop (Tom Wardrop) over 13 years ago. Updated almost 12 years ago.

Status:
Rejected
Target version:
[ruby-core:36559]

Description

Assuming there's no technical limitation or ambiguities, I suggest that the shorthand syntax for symbol's in the context of an array, be applied to strings also.

E.g. {'key': 'value'}

I don't believe there are any syntax ambiguous that this would give rise to. The only consideration that may need to be made, is if there are plans to support shorthand syntax for quoted symbols, e.g. {'key': 'value'}. If quoted symbols are off the table, then there's no harm in implementing a shorthand hash syntax for strings. This may stem the growing problem of what I like to call 'symbolitis' , where symbol's are selected as the key type purely for their aesthetics and ease of use, even when strings are a more appropriate choice.

Thoughts?


Files

bm.rb (2.54 KB) bm.rb Benchmark comparing hash and string keys for hashes with various hit rates drbrain (Eric Hodel), 08/16/2011 03:18 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #4276: Allow use of quotes in symbol syntactic sugar for hashesClosedmatz (Yukihiro Matsumoto)01/13/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0