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

tsalm tsalm at free.fr
Tue Dec 9 23:50:01 PST 2008


Le Wed, 10 Dec 2008 03:16:49 +0100, Denis Koroskin <2korden at gmail.com> a  
écrit:

> On Wed, 10 Dec 2008 03:24:48 +0300, Jarrett Billingsley  
> <jarrett.billingsley at gmail.com> wrote:
>
>> 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);
>> }
>
> *And* allows overriding them!


Thanks you all !


More information about the Digitalmars-d-learn mailing list