From: Daniel Luz Date: 2008-12-07T10:35:37+09:00 Subject: [ruby-core:20401] Re: More powerful method arguments When I first heard of arbitrary optional argument positioning, my first expectation was that *varargs would be allowed before them too (having the least priority). Not that I find it particularly useful, it's just what I originally expected. On Sat, Dec 6, 2008 at 12:53, Rados�aw Bu�at wrote: > (I'm thinking very loudly, don't get it to seriously) > I was thinking about "mandatory arguments after optional" in 1.9 > lately and I cannot think about real use case with it but... if we can > do this > > def foo(*args, options = {}) > end > > then we could use optional argument "options" like named arguments > list (which could be empty). > foo(1, 2, 3) > foo(1, 2, 3, controller: "foo", action: "bar") Though there's an important problem here: in your first case, `options` would be "3", not the empty Hash. And if you are completely sure the last argument is a Hash (i.e., the user will always supply named arguments), you could just leave it as a non-optional argument. And before coming up with some kind of hack to work around that (say, opening an exception when the default value of the last argument is an empty Hash), I'd rather have actual named arguments. -- Daniel