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.

Reply via email to