Tuple DIP

Martin Nowak code+news.digitalmars at dawg.eu
Fri Feb 16 20:01:02 UTC 2018


On 01/14/2018 12:21 AM, Timon Gehr wrote:
>> what would be the equivalent of this ?
>> ` writeln(tuple!("x", "y", "z")(2, 3, 4).y); `
> 
> It would continue to work the same way.
> 
> I did consider adding a proposal for built-in named tuple syntax:
> 
> writeln((x: 2, y: 3, z: 4).y);
> 
> (int a, double b) t = (a: 1, b: 2.0);
> int x = t.a;
> double y = t.b;

Tuples are anonymous bundles, when you want a product type with field
names use a struct.


More information about the Digitalmars-d mailing list