1 The "break" and "continue" statements allow to abort a running loop or to 2 prematurely advance to the next cycle. 3 4 -- Expect stdout -- 5 Testing break: 6 - Iteration 0 7 - Iteration 1 8 - Iteration 2 9 - Iteration 3 10 - Iteration 4 11 - Iteration 5 12 - Iteration 6 13 - Iteration 7 14 - Iteration 8 15 - Iteration 9 16 - Iteration 10 17 18 Testing continue: 19 - Iteration 0 20 - Iteration 2 21 - Iteration 4 22 - Iteration 6 23 - Iteration 8 24 -- End -- 25 26 -- Testcase -- 27 Testing break: 28 {% 29 let i = 0; 30 31 while (true) { 32 print(" - Iteration ", i, "\n"); 33 34 if (i == 10) 35 break; 36 37 i++; 38 } 39 %} 40 41 Testing continue: 42 {% 43 for (i = 0; i < 10; i++) { 44 if (i % 2) 45 continue; 46 47 print(" - Iteration ", i, "\n"); 48 } 49 %} 50 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt