Forum: Ruby-core [ruby-trunk - Bug #7663][Open] Unable to invoke a method with `**kwargs` if the receiver doesn't def

428167a3ec72235ba971162924492609?d=identicon&s=25 Yehuda Katz (wycats)
on 2013-01-06 23:13
(Received via mailing list)
Issue #7663 has been reported by wycats (Yehuda Katz).

----------------------------------------
Bug #7663: Unable to invoke a method with `**kwargs` if the receiver
doesn't define keyword arguments
https://bugs.ruby-lang.org/issues/7663

Author: wycats (Yehuda Katz)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 2.0.0dev


This works:

  def hello
    puts "hello"
  end

  hello(*[])

This does not:

  def hello
    puts "hello"
  end

  hello(**{})

I may be misunderstanding the idea behind the keyword arguments, but I
would expect them to behave similarly to regular arguments when used
with splat.
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 matz (Yukihiro Matsumoto) (Guest)
on 2013-01-07 02:39
(Received via mailing list)
Issue #7663 has been updated by matz (Yukihiro Matsumoto).

Status changed from Open to Rejected

Unlike regular argument, empty keyword argument is not equal to empty
regular list.

Matz.

----------------------------------------
Bug #7663: Unable to invoke a method with `**kwargs` if the receiver
doesn't define keyword arguments
https://bugs.ruby-lang.org/issues/7663#change-35239

Author: wycats (Yehuda Katz)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 2.0.0dev


This works:

  def hello
    puts "hello"
  end

  hello(*[])

This does not:

  def hello
    puts "hello"
  end

  hello(**{})

I may be misunderstanding the idea behind the keyword arguments, but I
would expect them to behave similarly to regular arguments when used
with splat.
F24ff61beb80aa5f13371aa22a35619c?d=identicon&s=25 mame (Yusuke Endoh) (Guest)
on 2013-01-07 04:47
(Received via mailing list)
Issue #7663 has been updated by mame (Yusuke Endoh).


In the current design, keyword arguments are NOT omittable at a callee
side.
In other words, you cannot pass keyword arguments to a method that does
not support keyword argments.

Other possible behavior is to ignore the passed arguments silently (as
you expected), but I'm afraid if it is rather error-prone than useful.
It tends to hide bugs.

If you really want to do so, you can use `**` parameter explicitly.

  def hello(**dummy)
    puts "hello"
  end

A bare `**` (#7662) is indeed useful in this use case.  I'm not so
positive to this use case itself, though.
----------------------------------------
Bug #7663: Unable to invoke a method with `**kwargs` if the receiver
doesn't define keyword arguments
https://bugs.ruby-lang.org/issues/7663#change-35251

Author: wycats (Yehuda Katz)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 2.0.0dev


This works:

  def hello
    puts "hello"
  end

  hello(*[])

This does not:

  def hello
    puts "hello"
  end

  hello(**{})

I may be misunderstanding the idea behind the keyword arguments, but I
would expect them to behave similarly to regular arguments when used
with splat.
This topic is locked and can not be replied to.