This article focuses on the use of logical operators in Lua, and is the basic knowledge of LUA's introductory learning, and the friends you need can refer to
The following table lists the logical operators that are supported by all LUA languages. Suppose variable a holds true, and variable B holds false:
Example
Try the following example to understand the logical operators provided by all of the LUA programming languages:
The code is as follows:
A = 5
b = 20
if (A and B)
Then
Print ("line 1-condition is true")
End
if (A or B)
Then
Print ("line 2-condition is true")
End
--lets change the value OFA and b
A = 0
b = 10
if (A and B)
Then
Print ("line 3-condition is true")
Else
Print ("line 3-condition are not true")
End
if (not (A and B))
Then
Print ("line 4-condition is true")
Else
Print ("line 3-condition are not true")
End
When the above program is established and executed, it produces the following results:
The code is as follows:
Line 1-condition is True
Line 2-condition is True
Line 3-condition is True
Line 3-condition are not true