HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Lua programming language flow control statements be programmed with one or more conditional statement to set. Executes the specified program code if the condition is true, execute other code is specified in the condition is false.
The following is a typical process control flow chart:
Conditional expression control structure can be any value, Lua considered false and nil as false, true and non-nil is true.
It should be noted Lua 0 is true:
--[ 0 为 true ] if(0) then print("0 为 true") end
The above code output is:
0 为 true
Lua control structure provides the following statement:
Statements | description |
---|---|
if statement | if statement consists ofa Boolean expression as a condition to judge, immediately followed by other statements. |
if /en. else statement | if and elsestatements canbeused withthe statement,the else statement is false in the code if the conditional expression. |
if nested statements | You can use one or more ofif or else ifstatementiforelse ifthe. |