Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
show how to constrain function references
  • Loading branch information
gfldex committed May 28, 2016
1 parent fffe595 commit 5b29667
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/Type/Signature.pod
Expand Up @@ -161,6 +161,16 @@ say limit-lines "a \n b \n c", Int; # "a \n b \n c"
For explicitly indicating the normal behaviour, C<:_> can be used, but this is
unnecessary. C<:(Num:_ $)> is the same as C<:(Num $)>.
=head3 X«Constraining signatures of Callables|function reference (constrain)»
To constrain block and subroutine references based on their signature write
the signature after the argument name.
sub f(&c:(Int, Str)) { say c(10, 'ten') };
sub g(Int $i, Str $s){ $s ~ $i };
f(&g);
# OUTPUT«ten10␤»
=head3 X«Constraining Return Types|-->;returns»
The token C<-->> followed by a type will force a type check on successful
Expand Down

0 comments on commit 5b29667

Please sign in to comment.