Lua Programming/How to Lua/repeat
A repeat loop is a conditional loop construct that repeatedly executes a block of instructions whilst the condition is true. The repeat statement is used together with an until syntactical cocomponent to produce a repeat loop:
attempts = 0 repeat print "Knock! Knock!" attempts = attempts + 1 until attempts == 10
The block of code within a repeat loop will always run at least once
Note than unlike while loops, with a repeat loop, the condition is evaluated after the block within the loop. This means that the block of code within a repeat loop will always run at least once.
Last modified on 19 March 2012, at 21:22