Lua learning (6)--Lua process control

The result of the conditional expression of the control structure can be any value, and Lua considers false and nil to be false, and true and non-nil to be true.

Note that 0 is true in Lua:

--[ 0 为 true ]
if(0)
then
    print("0 为 true")
end

The output of the above code is:

0true

Lua provides the following control structure statements:

An if statement
consists of a Boolean expression as a conditional statement followed by other statements.

The if…else statement
can be used in conjunction with the else statement to execute the else statement code when the if conditional expression is false.

if Nested Statements
You can use one or more if or else if statements within an if or else if.

Guess you like

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