Skip to content

Commit

Permalink
Improve example of where-clause on Signature
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun committed Apr 22, 2018
1 parent b2bda56 commit 608daf7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/Type/Signature.pod6
Expand Up @@ -174,10 +174,10 @@ the C<where>-clause of the last argument has access to all arguments of a
signature that are not part of a sub-signature. For a sub-signature place
the C<where>-clause inside the sub-signature.
sub one-of-them(:$a, :$b, :$c where { $a.defined ^^ $b.defined ^^ $c.defined }) {
$a // $b // $c
};
say one-of-them(c=>42); # OUTPUT: «42␤»
sub foo($a, $b where * == $a ** 2) { say "$b is a square of $a" }
foo 2, 4; # OUTPUT: «4 is a square of 2␤»»
# foo 2, 3;
# OUTPUT: «Constraint type check failed in binding to parameter '$b'…»
=head3 Constraining Optional Arguments
Expand Down

0 comments on commit 608daf7

Please sign in to comment.