Commit 90946b6
committed
Fix TaskArguments#deconstruct_keys with keys = nil
`#deconstruct_keys` should handle `keys == nil`, or `**rest` will be broken.
For example, the normal behavior looks like this:
```ruby
{a: 1, b: 2, c: 3} => {a:, **rest}
a # => 1
rest # => {b: 2, c: 3}
```
But without handling `keys == nil`, we'll get this:
```ruby
class Example
def initialize(hash) = @hash = hash
def deconstruct_keys(keys) = @hash.slice(*keys)
end
Example.new({a: 1, b: 2, c: 3}) => {a:, **rest}
# !> "#{inspect}: key not found: :a" (NoMatchingPatternKeyError)
```1 parent 0fdacef commit 90946b6
2 files changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
0 commit comments