[#104307] Float truncate — Eustáquio Rangel <eustaquiorangel@...>
Hi!
4 messages
2021/06/16
[ruby-core:104262] [Ruby master Feature#17950] Unable to pattern-match against a String key
From:
merch-redmine@...
Date:
2021-06-14 23:21:44 UTC
List:
ruby-core #104262
Issue #17950 has been updated by jeremyevans0 (Jeremy Evans).
Backport deleted (2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN)
ruby -v deleted (3.0.1)
Tracker changed from Bug to Feature
The fact that only symbol keys are supported is documented (https://docs.ruby-lang.org/en/master/doc/syntax/pattern_matching_rdoc.html#label-Patterns), so this is expected and not a bug. Switching to feature request.
----------------------------------------
Feature #17950: Unable to pattern-match against a String key
https://bugs.ruby-lang.org/issues/17950#change-92472
* Author: chucke (Tiago Cardoso)
* Status: Open
* Priority: Normal
----------------------------------------
I'm unable to parse against an internal hash, when the internal hash contains strings as keys:
```ruby
case {status: 200, headers: {"content-type" => "application/json"}, body: "bla"}
in { status: , headers: {"content-type" => type}, body: }
# syntax error, unexpected terminator, expecting literal content or tSTRING_DBEG or tSTRING_DVAR or tLABEL_END
# ...tus: , headers: {"content-type" => type}, body: }
```
however, this works:
```ruby
h = {"content-type" => "application/json"}
case {status: 200, headers: {"content-type" => "application/json"}, body: "bla"}
in { status: , headers: ^h, body: }
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>