lua-Loop(循环)
while
Syntax:
while(condition)
do
statement(s)
end
1 |
|
for
The for statement has two variants(变种): the numeric for and the generic for.
Numeric for (数值for循环)
for var=exp1,exp2,exp3 do
something
end
- exp1: initial condition
- exp2: final condition
- exp3: step
- this exp is optional,when absent, Lua assumes one as the step value.
1 |
|
Generic for (泛型for循环)
The generic for loop allows you to traverse(遍历) all values returned by an iterator function.
ipairs()
When the traversed value is nil, the for loop will terminate.
1 |
|
pairs()
When the traversed value is nil, the for loop will omit the nil value and continue to the rest.
1 |
|
repeat…until
Similiar to other programing language.
nested loop
Similiar to other programing language.
lua-Loop(循环)
https://jackiedai.github.io/2024/01/03/004lua/lua-Loop-循环/