Project

General

Profile

Actions

Bug #13717

closed

Calling lambda with keyword arguments inconsistent behavior

Added by hakunin (Michal Hantl) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin16]
[ruby-core:81916]

Description

Context: I am running a callback hook that can have multiple arguments (or none) and multiple keywords (or none).

The idea is to run this and just pass on the params:

hook.call(*args, **kw_args)

But I've encountered an issue which is an inconsistency at the same time:

hook = lambda { |a|
}

hook.call(:a, **{}) # works

kws = {};
hook.call(:a, **kws) # wrong number of arguments (2 for 1)

I would expect the params to just be passed if there are any, or none passed at all, if the object supplied is empty.


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #10856: Splat with empty keyword args gives unexpected resultsClosednobu (Nobuyoshi Nakada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0