> On 27 Nov 2019, at 01:04, William Michels via perl6-users
> <[email protected]> wrote:
> Hi Simon, can you explain to me what the "->" arrow is doing in your above?
> All I see in the docs is "->" used within the signature part of a sub.
Maybe it becomes clearer when you realize that a sub is nothing but a block
with a name?
So the same signature options that you see with a sub, are available with *ANY*
block in Raku:
These two are basically the same thing:
sub foo($a,$b) { ... }
foo(42,666);
dd &foo.name; # "foo"
dd &foo.^mro; # (Sub, Routine, Block, Code, Any, Mu)
my &foo = -> $a, $b { ... }
foo(42,666);
dd &foo.name; # ""
dd &foo.^mro; # (Block, Code, Any, Mu)
The only difference is that in the latter case, introspection shows that the
block doesn't have a name. And a longer list of parent classes for the
subroutine case.