Thanks for bearing with me on this one @kddnewton, I believe the most appreciated use cases would be for *exact-matching* JSON String *keys* against Hash Pattern String *keys* without the need to recursively symbolize all the keys in th...yertto (_ yertto)
kddnewton (Kevin Newton) wrote in #note-25: > We're not "locked out" of using non-symbolic keys in hash patterns because of a syntax restriction... > ... Whether or not using non-symbolic keys in *Hash Patterns* is a _"desired feature"...yertto (_ yertto)
The label syntax (`key:`) may have value, and... matz (Yukihiro Matsumoto) wrote in #note-23: > `expr => value` already works, is short, and is unambiguous. However - and perhaps this is best discussed in a separate proposal? - ...yertto (_ yertto)
Thanks for your consideration of this @matz ... along with https://bugs.ruby-lang.org/issues/22108#note-23 And I have a follow up question that I'll place in that issue. yertto (_ yertto)
Thanks @baweaver. (This proposal is not _just_ to free up String keys, but - yes - there must be a considerable amount of code and authors that have been, and will continue to be, affected just by this lack of support for String keys in...yertto (_ yertto)
Looking for an answer to my own question: > > [!NOTE] > ... I've found: * https://docs.ruby-lang.org/en/3.0/syntax/pattern_matching_rdoc.html > Note that only symbol keys are supported for hash patterns. * @baweaver said in [rubytalk...yertto (_ yertto)
BTW, what I was alluding to in my side question above was how adding _"hash colon"_ syntax (eg. `"key" : value`) to `Hash` could unlock pattern matching on string-keyed values. Previously `in {key: ...}` only matched symbol keys, so par...yertto (_ yertto)
> > ```ruby > ... Fair - I should have included `a = 1` - but yes - agreed - they do look confusing in isolation. Could the confusion be unfamiliarity, rather than complexity though? If we compare: ```ruby { name: "Alice", extra_key =>...yertto (_ yertto)
> (BTW, I had considered making whitespace the disambiguator. ie. { foo: bar } for symbol keys, { foo : bar } for computed keys, but I came up with a few reasons against it, and so went with the parentheses design instead. Someone else i...yertto (_ yertto)
# Non-symbolic hash keys with `expr : value` syntax Allow `expr : value` for non-symbolic hash keys. Almost 20 years in the making, the missing puzzle piece for Hash's "new" colon syntax: ```ruby h = { name: "symbol shorthan...yertto (_ yertto)