C# 7 Features - Tuples

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 5 08:43:43 PDT 2016


On Thursday, 25 August 2016 at 14:43:35 UTC, Dominikus Dittes 
Scherkl wrote:
>
> (int, int, int, string) fn()
> {
>    return (3, 2, 1, "meins");
> }
>
> int x, y, z;
> string s;
> (x, y, z, s) = fn();

Another solution is to support out argument declarations, as they 
are a more general feature. These could then be used as follows:

Tuple!(int, string) fn();
void unpack(T...)(Tuple!T, out T decls); // new phobos function

fn().unpack(int i, string s);

I think a combination of tuple slicing and unpack() overloads 
could allow ignoring leading or trailing tuple fields.


More information about the Digitalmars-d mailing list