From: Srinivas Jonnalagadda Date: 2006-03-03T02:13:22+09:00 Subject: Re: Confusion Over Keyword Arguments This has reference to the discussion in the article below. > http://djberg96.livejournal.com/51052.html From the discussion on parameters to Array.new therein, I got the feeling that there were two distinct issues that somehow got mixed up: (a) method signature -- how many arguments does it accept, which have defaults, etc., and (b) which set of arguments belong to the same signature. Just because of Array.new has a form that accepts size and default object, and another that accepts an array, it does _not_ directly lead to a capability to mix those arguments into the same call. Even today, there are sanity checks to prevent such things as Array.new(4, {}) { | i | i * i }, and such shall always be needed. And I feel that the warning that Ruby generates on evaluating the above, is very correct. Am I seriously missing something in Daniel's argument? Best regards, JS Berger, Daniel wrote: >> -----Original Message----- >> From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org] >> Sent: Wednesday, March 01, 2006 4:46 PM >> To: ruby-talk ML >> Subject: Re: Confusion Over Keyword Arguments > > > >> |How about "=" for keyword arguments instead >> |(such as in python)? >> >> Unfortunately, assignments are legal in argument list in Ruby. >> >> matz. > > That can be made to work, with the understanding that '=' in a method > call means 'keyword argument', not 'assignment', since there is no point > in doing an assignment in a method call. > > # Method definition, '=' means assignment (of default value): > def foo(bar, baz = 3) > ... > end > > # Method call, '=' means keyword > foo(baz = 5, bar = 2) > > For anyone who cares to read my past thoughts on the subject: > > http://djberg96.livejournal.com/51344.html > http://djberg96.livejournal.com/51052.html > http://djberg96.livejournal.com/50325.html > http://djberg96.livejournal.com/50162.html > > Regards, > > Dan