Andy Colson wrote:
> (Sorry if this dbl-posts, sent it from the wrong account the first time)
> 
> Hi all, what's wrong with this code:
> 
> use v6;
> 
> sub multireturn($x, $y)
> {
>       my $a = $x * 2;
>       my $b = $y * 2;
>       return($a, $b);
> }
> 
> my($a, $b) = multireturn(2, 3);

There's (nearly) nothing wrong with your code, only with the compiler ;-)

Rakudo doesn't support list assignment yet (that's where the error
message comes from), and doesn't support returning values either.

A workaround for now is to use arrays instead.

(The thing that's still wrong with your code is that you need a
whitespace after the 'my', otherwise my(...) should be parsed as a
function call).

Cheers,
Moritz


-- 
Moritz Lenz
http://perlgeek.de/ |  http://perl-6.de/ | http://sudokugarden.de/

Reply via email to