From: Greg McIntyre Date: 2003-11-19T22:37:25+09:00 Subject: Re: Again, Rite explanation needed (keyword args and new hash syntax) matz@ruby-lang.org (Yukihiro Matsumoto) wrote: > Basic Rule: > Double asterisk for grouping the rest of keyword arguments. Keyword > arguments don't mix positional arguments (including optional ones). Thanks for clearing that up! Is there some reason why you chose double asterisks (**)? Are we running out of punctuation? :) To me it seems a little too much like the * operator repeated. def f(*args); end f(**[[1,2,3]]) # => f(1,2,3) # logically, to me But not so because we need ** to do this def f(**args); end f(**{:a => 1, :b => 2, :c => 3}) # => f(a:1,b:2,c:3) Hmm... looks at keyboard for more punctuation... def f(~args); end f(~{:a => 1, :b => 2, :c => 3}) # => f(a:1,b:2,c:3) def f(+args); end f(+{:a => 1, :b => 2, :c => 3}) # => f(a:1,b:2,c:3) Isn't there a more natural syntax? Hmm... def f(a, b, [arguments]) # arguments is an Array end f(a, b, 1, 2, 3) f(a, b, [1, 2, 3].arguments) # => f(a,b,1,2,3) def f(a, b, {keywords}) # keywords is a Hash end f(a, b, x:10, y:20) f(a, b, {:x => 10}.keywords) # => f(a,b,x:10) What do people think? I know * is borrowed from somewhere but it's not very intuitive. As a university tutor, students always point at it and say, "What's *that* do?" -- Greg McIntyre ======[ greg@puyo.cjb.net ]===[ http://puyo.cjb.net ]===