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)
> yet another hash assoc syntax You're right — `:` is not an operator. And this change doesn't treat it as one. `:` works the same way it always has: you put something on the left, put `:` after it, and that something becomes the hash ...yertto (_ yertto)
No, its different from `{ "#{expr}": value }`. That would produce a `Symbol` for the key. eg. ``` expr = "key"; value = "val" { "#{expr}": value }.keys # => [:key] ``` Whereas using `():` the key stays unchanged (ie. as a `String` in t...yertto (_ yertto)
> [!WARNING] > ... # Computed hash keys with `(expr):` syntax Allow `{ (expr): value }` as a computed hash key. Almost 20 years in the making, the missing puzzle piece for Hash's "new" colon notation: ```ruby h = { name: "sym...yertto (_ yertto)