Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add example of named sub
Usage with an identifier is more common than without.
  • Loading branch information
Juerd committed Jul 9, 2018
1 parent d7b6f97 commit 0c0dc4c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/Type/Sub.pod6
Expand Up @@ -12,6 +12,12 @@ followed by C<prefix>, C<infix>, C<postfix>, C<circumfix>, or C<postcircumfix>;
then a colon and the operator name in a quote construct. For (post-)circumfix
operators separate the two parts by white space.
sub hello {
say "Hello, world!";
}
say &hello.^name; # OUTPUT: «Sub␤»
hello; # OUTPUT: «Hello, world!␤»
my $s = sub ($a, $b) { $a + $b };
say $s.^name; # OUTPUT: «Sub␤»
say $s(2, 5); # OUTPUT: «7␤»
Expand Down

0 comments on commit 0c0dc4c

Please sign in to comment.