kinx

Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.

This project is maintained by Kray-G

While statement

Overview

while statement is a pre-test loop. The condition will be evaluated at the head of loop.

while (a == 0) {
    // loop while a equals 0.
}

Infinite loop

If you put true or non-zero value at the condition, it means infinite loop. break statement is needed to exit an infinite loop.

while (true) {
    // infinite loop.
    if (codition) break;
}

Examples

Example 1. Normal case

Code

var a = 5;
while (a--) {
    System.println(a);
}

Result

4
3
2
1
0

Example 2. Infinaite loop

Code

var i = 0;
while (true) {
    if (i > 1000) break;
    ++i;
}
System.println(i);

Result

1001