From: Yusuke Endoh Date: 2011-10-19T00:31:44+09:00 Subject: [ruby-core:40209] Re: [Ruby 2.0 - Feature #5454] keyword arguments Hello, 2011/10/19 Joshua Ballanco : > � � # Ruby 2.0 proposal: > � � def foo(a: 1, b: 2, c: 3) > � � � � puts [a, b, c] > � � end > � � foo(a: 'one', b: 'two', c: 'three') #=> ["one", "two", "three"] > � � # Currently in MacRuby: > � � def foo(a: first, b: second, c: third) > � � � � puts [first, second, third] > � � end > � � foo(a: 'one', b: 'two', c: 'three') #=> ["one", "two", "three"] Interesting. Matz, which do you prefer? Could you tell me the detail of MacRuby's keyword arguments? What's happen when all arguments are not given? def foo(a: first, b: second) p [first, second] end foo(a: 1) #=> [1, nil] ?? # or #=> ArgumentError ?? Is there a feature to get the rest keyword arguments? def foo(a: first, b: second, **h) p [first, second, h] end foo(a:1, b:2, c:3, d:4) #=> [1, 2, {:c=>3, :d=>4}] How about this? def foo(x, a: first, b: second) p [x, first, second] end foo(a: 1, b: 2) #=> [{:a=>1, :b=>2}, nil, nil] ?? # or #=> wrong number of arguments ?? -- Yusuke Endoh