On 2020-01-22 10:25, ToddAndMargo via perl6-users wrote:
On 2020-01-21 16:17, Todd Chester via perl6-users wrote:
Hi All,

What is the syntax for returning two variable from a sub?

 > sub x(--> Int, UInt) { return(-2,4) };

===SORRY!=== Error while compiling:
Malformed return value (return constraints only allowed at the end of the signature)
------> sub x(--> Int⏏, UInt) { return(-2,4) };

Many thanks,
-T



The guys on the chat line gave me a work around:

subset Tuple where * ~~ (Int, UInt, Str);
sub f($a,$b,$c --> Tuple) { ($a,$b,$c) };
say f(-1, 'x', 5)
# out of order, fails.


And I just added:

RFE: returns for multiple variables #152
https://github.com/Raku/problem-solving/issues/152

And thanks to the guys on the chat line, I hvae a pretty
workaround.

Reply via email to