Input/Output multiple values from function
Simen Kjærås
simen.kjaras at gmail.com
Wed Aug 28 10:10:08 UTC 2019
On Wednesday, 28 August 2019 at 05:17:28 UTC, Jabari Zakiya wrote:
> Inside func2 I create an input value for func1 and then assign
> func1's 4 outputs to named variable. That's where the problems
> arise. func1 does some math based on the input and generates 4
> outputs.
>
> I can't do (a, b, c,d) = func1(i) directly.
> What do I do to assign the output of func1 to the individual
> variables?
import std.meta : AliasSeq;
import std.typecons : tuple;
auto fun() {
return tuple(1, "test");
}
unittest {
int a;
string b;
AliasSeq!(a, b) = fun;
assert(a == 1);
assert(b == "test");
}
--
Simen
More information about the Digitalmars-d-learn
mailing list