Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve with/orwith section examples
  • Loading branch information
skids committed Dec 25, 2015
1 parent 9a5d617 commit 0ac8b6c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions doc/Language/control.pod
Expand Up @@ -264,15 +264,20 @@ truth. In addition, it topicalizes on the condition, much like C<given>:
with "abc".index("a") { .say } # prints 0
These may be cascaded:
Instead of C<elsif>, C<orwith> may be used to chain definedness tests:
with $s.index("a") { "Found a at $_" }
orwith $s.index("b") { "Found b at $_" }
orwith $s.index("c") { "Found c at $_" }
else { "Didn't find a, b or c" }
# The below code says "Found a at 0"
my $s = "abc";
with $s.index("a") { say "Found a at $_" }
orwith $s.index("b") { say "Found b at $_" }
orwith $s.index("c") { say "Found c at $_" }
else { say "Didn't find a, b or c" }
You may intermix C<if>-based and C<with>-based clauses.
# This says "Yes"
if 0 { say "No" } orwith Nil { say "No" } orwith 0 { say "Yes" };
As with C<unless>, you may use C<without> to check for undefinedness,
but you may not add an C<else> clause:
Expand Down

0 comments on commit 0ac8b6c

Please sign in to comment.