Jarrett Billingsley wrote:
Tue, Jul 28, 2009 at 2:28 PM, Arthur Lloyd<v...@google.com> wrote:
Daniel Keep Wrote:
U comma(T,U)(T a, U b) { return b; }
Is there any reason you couldn't use something like that?
Sorry, this is probably a newbie question, but.. So instead of return a, b, c;
you now have to write return comma(a, comma(b, c)); ? How will that help?
typeof(T[$ - 1]) comma(T...)(T args) { return args[$ - 1]; }
There. Now you can do "comma(a, b, c)".
Still won't solve the problem Andrei rightly pointed out. But this will:
T[$-1] comma(T...)(lazy T args) {
foreach (a; args[0..$-1]) cast(void) a;
return args[$-1];
}
Stewart.