From: Pit Capitain Date: 2005-07-20T05:00:43+09:00 Subject: Re: [RCR] nil for unassigned keys Hi Daniel. > Then what about this? > > def baz(a, b=nil, c) ... end > > Isn't that just as easy to grasp as this? > > def baz(a, *b, c) ... end Yes it is. It was the following definition, which was confusing to mee: def bar(a, b=nil, c, d=nil, e) ... end > I think restricting this to “only if > there's a splat argument somewhere!” is pretty arbitrary. > > If you wanted the semantics of this, > > def baz(a, b=nil, c) ... end > > you'd have to write it like this, > > def baz(a, *dummy, b=nil, c) > dummy.empty? or raise ArgumentError > ... end > > which seems pretty annoying-for-no-reason. I was thinking of just adding some mandatory parameters after the parameter lists that are allowed today (of course before a block parameter). So the following would be allowed: def baz(a, b=nil, c) def baz(a, *b, c, d) def baz(a, b=nil, *c, d, e) but not the following: def baz(a, *b, c=nil) def baz(a, b=nil, c, d=nil, e) Of course, this is only my personal opinion. If you can think of other use cases where you'd like to have even more flexibility, please go ahead. In any case I'm looking forward to the RCR. Regards, Pit