@@ -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 L < C < NEXT > phaser|/language/phasers#NEXT> 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,26 @@ for @x -> $x {
927
951
928
952
prints "12".
929
953
954
+ If the L < C < LAST > phaser|/language/phasers#LAST> is present, it runs
955
+ before exiting the loop:
956
+
957
+ = begin code
958
+ my Int $i = 1;
959
+ while ($i < 10) {
960
+ if ($i % 5 == 0) {
961
+ last;
962
+ }
963
+
964
+ LAST {
965
+ say "The last number was $i.";
966
+ }
967
+ NEXT {
968
+ $i++;
969
+ }
970
+ }
971
+ # OUTPUT: «The last number was 5.»
972
+ = end code
973
+
930
974
= head1 X < redo|control flow, redo >
931
975
932
976
The C < redo > command restarts the loop block without evaluating the
0 commit comments