> On 22 Feb 2016, at 22:51, (via RT) <perl6-bugs-follo...@perl.org> wrote:
> 
> # New Ticket Created by   
> # Please include the string:  [perl #127600]
> # in the subject line of all future correspondence about this issue. 
> # <URL: https://rt.perl.org/Ticket/Display.html?id=127600 >
> 
> 
> Code sample:
> 
> my $anon = -> $x, $y {return $x * $y};
> 
> say $anon(3,7);
> 
> Produces this output:
> 
> Attempt to return outside of any Routine
>  in block <unit> at simple.pl6 line 3
> 
> 
> Since anonymous subroutine returns the product of the two numbers,
> one would think that a "return" would be acceptable within the code.

A pointy block (-> { }) or Callable is *not* a subroutine.  Therefore the error 
message is correct.

You can either make it an anonymous sub:

$ 6 'my $anon = sub ($x, $y) {return $x * $y}; say $anon(3,7)’
21

Or you can just leave it as the last value:

$ 6 'my $anon = -> $x, $y {$x * $y}; say $anon(3,7)’
21

This ticket can be closed as ENOTABUG, as far as I am concerned.



Liz

Reply via email to