Tuples citizenship
deadalnix
deadalnix at gmail.com
Fri Mar 2 03:37:45 PST 2012
Le 02/03/2012 11:10, Jonathan M Davis a écrit :
> On Friday, March 02, 2012 09:53:19 kennytm wrote:
>> You can just chain with
>>
>> return doSomething(findSplit(haystack, needle)[0]);
>>
>> if you just need the return value. Compare with 'out':
>>
>> R4 ignored;
>> R5 ignored2;
>> return doSomething(findSplit(haystack, needle, ignored, ignored2));
>>
>> How do you chain with _partial_ amount of return values with 'out'?
>
> If the function uses out, then you can chain the return value without losing
> the values which were assigned to the out arguments, but if you have a tuple,
> and you select one of the elements in the tuple to chain, you lose the others.
> The only way to get _all_ of the values in the tuple is to assign the tuple to
> a variable, in which case, you can't chain at all.
>
> - Jonathan M Davis
But you are assigning to a variable, you just declare it before.
Additionally, you loose all possibility to use auto.
More information about the Digitalmars-d
mailing list