"""
So when you want to pass keyword arguments, you should always use foo(k: expr) or foo(**expr). If you want to accept keyword arguments, in principle you should always use def foo(k: default) or def foo(k:) or def foo(**kwargs).
"""

Isn't `**expr` same with `**kwargs`?

https://ismailarilik.com

On Mon, May 15, 2023, 01:57 Frank J. Cameron via ruby-talk <ruby-talk@ml.ruby-lang.org> wrote:
>> wrong number of arguments (given 2, expected 0..1) (ArgumentError)
>
>Here is some code that reproduces the error
>
>module DeprecationSuppressor
>  def initialize(*)
>    puts 'in DeprecationSuppressor::initialize'
>    super
>  end
>end
>Selenium::WebDriver::Logger.prepend DeprecationSuppressor

'In Ruby 3.0, positional arguments and keyword arguments will be separated. ... In Ruby 3, a method delegating all arguments must explicitly delegate keyword arguments in addition to positional arguments. ... So when you want to pass keyword arguments, you should always use foo(k: expr) or foo(**expr). If you want to accept keyword arguments, in principle you should always use def foo(k: default) or def foo(k:) or def foo(**kwargs). ... Alternatively, if you do not need compatibility with Ruby 2.6 or prior and you don’t alter any arguments, you can use the new delegation syntax (...) that is introduced in Ruby 2.7."

https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

 ______________________________________________
 ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
 To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
 ruby-talk info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-talk.ml.ruby-lang.org/