Lua repeat ... until loop
Lua programming language repeat ... until loop statement is different for and while loops, conditional statements for and while loop d at the beginning of the current cycle is determined at execution, and repeat ... until loop conditional statement after the end of the current cycle is determined .
grammar
The repeat Lua programming language ... until loop syntax:
repeat statements until( condition )
repeat ... until the conditions are succeeding, so repeat ... until loop body to be run at least once inside.
statements (loop statements) may be one or more statements, condition (condition) can be any expression, the loop body statement is true in the condition (condition).
In the condition (condition) is false skips the current cycle and begin execution of the script followed by the statement.
Lua repeat ... until loop flow chart is as follows:
Examples
--[ 变量定义 --] a = 10 --[ 执行循环 --] repeat print("a的值为:", a) a = a + 1 until( a > 15 )
Implementation of the above code, program output is:
a的值为: 10 a的值为: 11 a的值为: 12 a的值为: 13 a的值为: 14 a的值为: 15