ruby-core

Mailing list archive

[ruby-core:81916] [Ruby trunk Bug#13717] Calling lambda with keyword arguments inconsistent behavior

From: michal.hantl@...
Date: 2017-07-05 10:51:16 UTC
List: ruby-core #81916
Issue #13717 has been reported by hakunin (Michal Hantl).

----------------------------------------
Bug #13717: Calling lambda with keyword arguments inconsistent behavior
https://bugs.ruby-lang.org/issues/13717

* Author: hakunin (Michal Hantl)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin16]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
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.



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

In This Thread

Prev Next