Issue #11860 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

With recent commits to the master branch, keyword splats of empty hashes do not pass positional arguments to methods or cause an empty hash to be added to an array.

----------------------------------------
Bug #11860: Double splat does not work on empty hash assigned via variable
https://bugs.ruby-lang.org/issues/11860#change-81363

* Author: sawa (Tsuyoshi Sawada)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
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("foo", **{}) # => 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("foo", **h) # => wrong number of arguments (given 1, expected 0)
```




-- 
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>