Loops

Loops are one of the basic constructs in a language. So, let's see the loops that haXe supports.

While

While is a loop that is executed as long as a condition is true. It has the following two syntaxes:

while(condition) exprToBeExecuted;
doexprToBeExecuted while(condition);

With the first syntax, the condition is tested before entering the loop. That means, if the condition is not true, exprToBeExecuted will never be executed.

With the second syntax, the condition is tested after the execution of exprToBeExecuted. This way, you are sure that exprToBeExecuted will be executed at least once. The following are two simple examples to help you understand how these syntaxes have to be used:

public static function main() { var i : Int = 0; while(i< ...

Get haXe 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.