Skip to content

Commit 6d341b8

Browse files
committed
show that try provides a return value
1 parent ecd98a5 commit 6d341b8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/Language/exceptions.pod6

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@ return value of itself. We can therefore use it as a RHS.
154154
# OUTPUT: «99999␤oh no␤»
155155
=end code
156156
157+
Try blocks support C<else> blocks indirectly by returning the return value of
158+
the expression or L<Nil|/type/Nil> if an exception was thrown.
159+
160+
with try +"♥" {
161+
say "this is my number: $_"
162+
} else {
163+
say "not my number!"
164+
}
165+
# OUTPUT: «not my number!␤»
166+
157167
=head1 Throwing exceptions
158168
159169
Exceptions can be thrown explicitly with the C<.throw> method of an

0 commit comments

Comments
 (0)