Issue #6353 has been updated by nobu (Nobuyoshi Nakada).
=begin
Almost implemented, and another question.
What should happen in this case?
def foo(k1: 1)
p k1
end
h = {k1: "bar"}
foo(k1: "foo", **h) # <== conflict
(({k1})) will be (({"foo"})), or (({"bar"}))?
Or an exception should be raised?
=end
----------------------------------------
Feature #6353: caller-side **
https://bugs.ruby-lang.org/issues/6353#change-26260
Author: mame (Yusuke Endoh)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version: 2.0.0
Relating to keyword argument (#5474), there are some requests for
caller-side **. [ruby-core:40518]
def foo(k1: 1, k2: 2)
p [k1, k2]
end
h = {k2: "bar"}
foo(k1: "foo", **h) # <== here
#=> ["foo", "bar"]
Marc-Andre explained the use case [ruby-core:41772], and matz agreed with
this feature. [ruby-core:41818]
However, it conflicts with power expression when parens are omitted:
foo **h # foo(**h)? or foo.send("**", h)?
Which should it be interpreted?
Anyway, I have no idea to avoid yacc conflict.
Nobu, could you please try to implement it?
--
Yusuke Endoh <mame / tsg.ne.jp>
--
http://bugs.ruby-lang.org/