How to unpack a tuple into multiple variables?

TTK Ciar ttk at ciar.org
Mon Feb 5 21:21:33 UTC 2024


I've been using AliasSeq for that (and aliasing it to "put" for 
easier use):


```d
import std.meta;
alias put = AliasSeq;

auto foo() { return tuple(1, 2, 3); }

int main(string[] args) {
   int x, y, z;
   put!(x, y, z) = foo();
   writeln(x, y, z);
   return 0;
}
```

My mnemonic: "put" is "tup" backwards, and undoes what tuple does.


More information about the Digitalmars-d-learn mailing list