Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 495 Bytes

File metadata and controls

35 lines (31 loc) · 495 Bytes

Empty Expressions

You are also allowed to leave the expression part of a for loop blank.

~void main() {
for (int i = 0;;i++) {
    IO.println(i);
}
// 0
// 1
// 2
// 3
// ... and so on
~}

This means that each time through there is no check to see if the loop will exit. The loop will only exit if there is an explicit break somewhere.

~void main() {
for (int i = 0;;i++) {
    if (i == 5) {
        break;
    }
    IO.println(i);
}
// 0
// 1
// 2
// 3
// 4
~}