@@ -85,6 +85,12 @@ You have to watch out for this in most languages anyway to prevent things
85
85
from getting accidentally commented out. Many of the examples below may
86
86
have unnecessary semicolons for clarity.
87
87
88
+ = head1 X < Phasers|control flow,Phasers >
89
+
90
+ Blocks may have phasers: special labeled blocks that break their execution
91
+ into phases that run in particular phases. See the page
92
+ L < phasers|/language/phasers > for the details.
93
+
88
94
= head1 X < do|control flow,do >
89
95
90
96
The simplest way to run a block where it cannot be a stand-alone statement
@@ -912,6 +918,24 @@ for @x -> $x {
912
918
913
919
prints "1245".
914
920
921
+ If the C < NEXT > L < phaser|/language/phasers > is present, it runs before the next iteration:
922
+
923
+ = begin code
924
+ my Int $i = 0;
925
+ while ($i < 10) {
926
+ if ($i % 2 == 0) {
927
+ next;
928
+ }
929
+
930
+ say "$i is odd.";
931
+
932
+ NEXT {
933
+ $i++;
934
+ }
935
+ }
936
+ # OUTPUT: «1 is odd.3 is odd.5 is odd.7 is odd.9 is odd.»
937
+ = end code
938
+
915
939
= head1 X < last|control flow, last >
916
940
917
941
The C < last > command immediately exits the loop in question.
@@ -927,6 +951,25 @@ for @x -> $x {
927
951
928
952
prints "12".
929
953
954
+ If the C < LAST > L < phaser|/language/phasers > is present, it runs:
955
+
956
+ = begin code
957
+ my Int $i = 1;
958
+ while ($i < 10) {
959
+ if ($i % 5 == 0) {
960
+ last;
961
+ }
962
+
963
+ LAST {
964
+ say "The last number was $i.";
965
+ }
966
+ NEXT {
967
+ $i++;
968
+ }
969
+ }
970
+ # OUTPUT: «The last number was 5.»
971
+ = end code
972
+
930
973
= head1 X < redo|control flow, redo >
931
974
932
975
The C < redo > command restarts the loop block without evaluating the
0 commit comments