Project

General

Profile

Actions

Bug #11860

closed

Double splat does not work on empty hash assigned via variable

Added by sawa (Tsuyoshi Sawada) over 8 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]
[ruby-core:72429]

Description

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

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.

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)

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14183: "Real" keyword argumentClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0