Ruby2: keyword argument

Will Ruby2 support required keyword argument? AFAIR, Python doesn’t:

def foo(a, b=2):

foo(a=1) # ok
foo(a=1, b=2) # ok

and Perl6 will:

sub foo(+$a is required, +$b is required) {

}

note: i’m not sure about the exact P6 syntax for calling

foo(a: 1); # error!
foo(a: 1, b: 2) # ok

This is being discussed at perl6-language list right now. I also believe
with the poster that basically said required keyword argument is
essential for a “proper” keyword-based API.

Also, implementation-wise, will the introduction of keyword arguments in
Ruby2 bring a performance hit to all method calls, including positional
arguments? (I.e., will normal/positional argument calls in Ruby2 be
slower than Ruby1?)

···


dave

python does and so will ruby2.
See matz slide from latest rubyconf for other info.
basically, you’ll write
method(name: value)
where name:value is the new hash literal for :name => value

···

il Wed, 21 Apr 2004 00:34:14 +0900, David Garamond lists@zara.6.isreserved.com ha scritto::

Will Ruby2 support required keyword argument? AFAIR, Python doesn’t:

def foo(a, b=2):

foo(a=1) # ok
foo(a=1, b=2) # ok