From: Pit Capitain Date: 2005-07-20T00:08:31+09:00 Subject: Re: [RCR] nil for unassigned keys Daniel Brockman schrieb: > ... > That reminds me, I promised I would write an RCR for > allowing trailing argument after the splatting one, like so: > ... > I think the only reasonable thing to do is to fill optional > argument slots from left to right, as is done now: I think so, too. > ... > This would also reasonably mean that mixing optional and > mandatory arguments would become allowed: > > def bar(a, b=nil, c, d=nil, e) ... end > > foo 1 # ArgumentError > foo 1, 2 # ArgumentError > foo 1, 2, 3 # a=1, b=nil, c=2, d=nil, e=3 > foo 1, 2, 3, 4 # a=1, b=2, c=3, d=nil, e=4 > foo 1, 2, 3, 4, 5 # a=1, b=2, c=3, d=4, e=5 I don't like this. It is hard to see which value is put into which parameter. Picking some arguments from the left and from the right and stuffing the rest in the splatted parameter is easier to grasp, at least for me. I think the chances to get the RCR accepted are higher if you drop this feature. > What do people think? Does this all seem reasonable? > Eric Mahurin had another good example of a use case: > > def []= *coordinates, value Yes. Please do write the RCR! Regards, Pit