[ruby-core:95970] [Ruby master Bug#16371] Inconsistent usage of Double splat operator
From:
matz@...
Date:
2019-11-27 01:35:21 UTC
List:
ruby-core #95970
Issue #16371 has been updated by matz (Yukihiro Matsumoto).
I think this inconsistency is a bug. Double splat in hash expressions needs to work as interpolation.
Matz.
----------------------------------------
Bug #16371: Inconsistent usage of Double splat operator
https://bugs.ruby-lang.org/issues/16371#change-82805
* Author: dmytro.vasin (Dmytro Vasin)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.6.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Here is an issue with a weird behavior of ruby double splat operator:
```
a = {a: 'a'}
b = {'b' => 'b'}
{x: 'x', **a}
#=> {:x=>"x", :a=>"a"}
{x: 'x', **b}
#=> TypeError (hash key "b" is not a Symbol)
```
When I do that implicitly, it works:
```
{x: 'x', **{'b' => 'b'}}
#=> {:x=>"x", "b"=>"b"}
```
At the same time:
```
{**{'b' => 'b'}}
# TypeError (hash key "b" is not a Symbol)
```
From my point of view, it definitely works inconsistently.
Could you help with this example or give an advice? (maybe I used it incorrectly?)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>