Skip to content

Commit 95d0ec0

Browse files
stonedJJ
authored andcommitted
Rework Parameter.type_captures example
1 parent c5079b4 commit 95d0ec0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

doc/Type/Parameter.pod6

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,19 @@ given $! { .message.say };
342342
Type captures may be used at the same time as
343343
L<type constraints|/type/Signature#Type_constraints>.
344344
345-
=for code
345+
=begin code
346346
sub d(::T Numeric $x, T $y) {};
347347
d(4, 5); # OK
348348
d(4e0, 5e0); # OK
349-
d(4e0, 5); # Fails when binding $y
350-
d("four", "five"); # Fails when binding $x
349+
350+
try d(4e0, 5);
351+
given $! { .message.say };
352+
# OUTPUT: «Type check failed in binding to parameter '$y'; expected Num but got Int (5)␤»
353+
354+
try d("four", "five");
355+
given $! { .message.say };
356+
# OUTPUT: «Type check failed in binding to parameter '$x'; expected Numeric but got Str ("four")␤»
357+
=end code
351358
352359
=head2 method sub_signature
353360

0 commit comments

Comments
 (0)