RosettaCodeData/Task/Call-a-function/Ecstasy/call-a-function-7.ecstasy
2023-07-01 13:44:08 -04:00

16 lines
614 B
Text

module ObtainReturnValues {
(Int, String, Dec) foo() {
return 3, "hello!", 9.87;
}
void run() {
foo(); // ignore return values
Int i1 = foo(); // only use first returned value
(Int i2, String s2) = foo(); // only use first two returned values
(Int i3, String s3, Dec d3) = foo(); // use all returned values
Tuple<Int, String, Dec> t = foo(); // alternatively, get the tuple instead
@Inject Console console;
console.print($"{i3=}, {s3=}, {d3=}, {t=}");
}
}