Nasal Loops: Difference between revisions

Jump to navigation Jump to search
m
Line 125: Line 125:
   print( c += 1 );
   print( c += 1 );
print("end of loop\n");
print("end of loop\n");
</syntaxhighlight>
== skip or exit loops prematurely ==
If you want to skip a single loop use "continue" or to exit a loop prematurely use "break".
<syntaxhighlight lang="nasal">
for (var i=0; i < 10; i+=1) {
    # loop body
    # don't do loop for i == 3
    if ( i == 3 ) continue;
    # exit for other reason
    if ( want_to_quit ) break;
}
</syntaxhighlight>
</syntaxhighlight>


546

edits

Navigation menu