let (x,y) = ...

Nick Treleaven via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Feb 19 09:00:59 PST 2015


On 19/02/2015 14:59, John Colvin wrote:
> On Thursday, 19 February 2015 at 13:52:29 UTC, Nick Treleaven wrote:
>> On 19/02/2015 04:38, thedeemon wrote:
>>> int x, y, z, age;
>>> string name;
>>>
>>> let (name, age) = getTuple();           // tuple
>>> let (x,y,z) = argv[1..4].map!(to!int);  // lazy range
>>> let (x,y,z) = [1,2,3];                  // array
>>>
>>> SomeStruct s;
>>> let (s.a, s.b) = tuple(3, "piggies");
>>
>> Alternatively std.typetuple.TypeTuple can be used instead of let
>
> not for ranges and arrays though

Yes, but `tuple` overloads could be added for those. Tuple already 
supports construction from a static array:

     int a, b;
     TypeTuple!(a, b) = Tuple!(int, int)([3, 4]);



More information about the Digitalmars-d-announce mailing list