Project

General

Profile

Bug #11860

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

When an empty hash is given as a literal, the double splat operates on it, and leaves nothing, which is expected.

```ruby


class String

def foo; end

end



[**{}] # => []

"foo".foo(**{}) # => nil

"foo".send(**{}) # => nil
```


However, when an empty hash is given via variable, the double splat retains an empty hash in place.

```ruby


h = {}



[**h] # => [{}]

"foo".foo(**h) # => wrong number of arguments (given 1, expected 0)

"foo".send(**h) # => wrong number of arguments (given 1, expected 0)
```

Back