Lua learning notes --- selection, cyclic statements
Select statement
Form:
1> if condition then branch end
Note: parentheses can be removed.
2> if condition then branch 1 else branch 2 end
3> if condition 1 then branch 1 elseif condition 2 then branch 2 end
2. Loop statements
1> while LOOP
Note: No auto-subtraction, auto-Addition
2> for Loop
Form: fZ signature? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> cipher + CBkbyC31tanIGVuZCA8YnI + CrK9vfi/cipher =" http://www.2cto.com/uploadfile/Collfiles/20150214/20150214083751178.png "alt =" here write picture description "title = "\ ">
Note: I starts from 0 and Adds 1 each time until I = 4 and runs print five times. The three parameters (expressions) IN THE for loop are calculated once before the loop, it does not run in every loop. However, local variables in the for loop can only be seen internally.
3> repeat ...... Until statement
Form: repeat branch until Condition
4> break Out Loop