Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
signatures can be smart matched against a list
  • Loading branch information
gfldex committed Jun 17, 2016
1 parent 85c37a8 commit ae72862
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/Type/Signature.pod
Expand Up @@ -48,6 +48,17 @@ closure.
f(&won't-work); # fails at runtime
f(-> Int { 'this works too' } );
Smart matching signatures against a List is supported.
my $sig = :(Int $i, Str $s);
say (10, 'answer') ~~ $sig;
# OUTPUT«True␤»
given ('answer', 10) {
when :(Str, Int) { say 'match' }
when $sig { say 'mismatch' }
}
# OUTPUT«match␤»
=head2 Parameter Separators
A signature consists of zero or more I<L<parameters|Parameter>>, separated by comma.
Expand Down

0 comments on commit ae72862

Please sign in to comment.