Skip to content

Commit

Permalink
Include example without try sink
Browse files Browse the repository at this point in the history
Since normally you don't need any trys
  • Loading branch information
zoffixznet committed May 14, 2017
1 parent d15b0c7 commit 04355a4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion doc/Language/traps.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,21 @@ exception to be thrown. That means this construct will throw, despite the C<try>
# OUTPUT: «The spawned process exited unsuccessfully (exit code: 42)␤»
This is because C<try> receives a C<Proc> and returns it, at which point it sinks and
throws. Explicitly sinking it inside the C<try> avoids the issue:
throws. Explicitly sinking it inside the C<try> avoids the issue
and ensures the exception is thrown inside the C<try>:
try sink run("perl6", "-e", "exit 42");
say "still alive";
# OUTPUT: «still alive␤»
If you're not interested in catching any exceptions, then use an anonymous
variable to keep the returned C<Proc> in; this way it'll never sink:
$ = run("perl6", "-e", "exit 42");
say "still alive";
# OUTPUT: «still alive␤»
=head1 Using Shortcuts
=head2 The ^ twigil
Expand Down

0 comments on commit 04355a4

Please sign in to comment.