Tuples citizenship

Jonathan M Davis jmdavisProg at gmx.com
Fri Mar 2 02:10:32 PST 2012


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


More information about the Digitalmars-d mailing list