Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
This project is maintained by Kray-G
do-while
statement is a post-test loop.
The condition will be evaluated at the tail of loop.
This loop will be performed 1 time at least.
do {
// loop while a equals 0.
} while (a == 0);
If you put true
or non-zero value at the condition, it means infinite loop.
break
statement is needed to exit an infinite loop.
do {
// infinite loop.
if (codition) break;
} while (true);
This is exactly the same as while
, therefore you had better use while
for readability.
var a = 5;
do {
System.println(a);
} while (a--);
5
4
3
2
1
0
var i = 0;
do {
if (i > 1000) break;
++i;
} while (true);
System.println(i);
1001