Lua learning (5)--Lua loop

The Lua language provides the following loop processing methods:
while loop
Let the program execute certain statements repeatedly when the condition is true. The condition is checked for true before executing the statement.
for loop
Repeats the execution of the specified statement, and the number of repetitions can be controlled in the for statement.
repeat...until
Repeats the loop until the specified condition is true.
Loop Nesting
You can nest one or more loop statements within a loop (while do … end;for … do … end;repeat … until;)

loop control statement

The loop control statement is used to control the flow of the program to realize various structural modes of the program.
Lua supports the following loop control statements:

break statement
Exits the current loop or statement and begins script execution of the statement immediately following.

Infinite loop

In the loop body, if the condition is always true, the loop statement will be executed forever. The following takes the while loop as an example:

while( true )
do
   print("循环将永远执行下去")
end

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325588272&siteId=291194637