Is it possible to avoid creating temporary scalars when returning multiple arrays from a function:
use v6;
sub func() {
my @a = 1..3;
my @b = 5..10;
return @a, @b;
}
my ($x, $y) = func();
my @x := $x;
my @y := $y;
say "x: ", @x; # OUTPUT: x: [1 2 3]
say "y: ", @y; # OUTPUT: y: [5 6 7 8 9 10]
I would like to avoid creating the temporary variables $x and $y.
Note: It is not possible to replace the function call with
my (@x, @y) = func()
since assignment of a list to an Array is eager and therefore both the returned arrays end up in @x.