myClass.add(something)(otherthings)(thisToo);

Jarrett Billingsley jarrett.billingsley at gmail.com
Tue Dec 9 16:24:48 PST 2008


On Tue, Dec 9, 2008 at 7:00 PM, BCS <ao at pathlink.com> wrote:
> class C
> {
>   final void add(T...)(T t)
>   {
>       foreach(int i,_;T)
>           _add(t[i]);
>   }
>   //.....
> }
>
>
> (new C).add(something, otherthings, thisToo);

If all the params are the same type, typesafe variadics are a more
efficient/less code-bloaty way to do it.

void add(int[] things...)
{
    foreach(thing; things)
        _add(thing);
}


More information about the Digitalmars-d-learn mailing list