control flow default when
Documentation for control flow
default when assembled from the following types:
From Control flow
A block containing a
default statement will be left immediately when the sub-block after the
default statement is left. It is as though the rest of the statements in the block are skipped.
given 42# The above block evaluates to 43
when statement will also do this (but a
when statement modifier will not.)
smartmatch the topic (
$_) against a supplied expression such that it is possible to check against values, regular expressions, and types when specifying a match.
for 42, 43, "foo", 44, "bar"# OUTPUT: «42␤43␤Not an Int or a Bar␤44␤Bar␤»
In this form, the
when construct acts much like a set of
else statements. Be careful with the order of the
when statements. The following code says
given 42# OUTPUT: «Int␤»
when statement or
default statement causes the outer block to return, nesting
default blocks do not count as the outer block, so you can nest these statements and still be in the same "switch" just so long as you do not open a new block:
given 42# OUTPUT: «42»
when statements can smartmatch against Signatures.