Project

General

Profile

Actions

Bug #10708

closed

In a function call, double splat of an empty hash still calls the function with an argument

Added by Gondolin (Damien Robert) over 6 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
[ruby-core:67394]

Description

Consider this:

def foo; end
foo(*[]) #Splatting an empty list is ok
foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

This is annoying in a function that is a wrapper around another function and just process some keywords:

def wrapper(*args, keyword: true, **others)
  puts keyword
  wrappee(*args,**others) #here this code will fail if others is empty
end

Related issues

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

Also available in: Atom PDF