This article mainly introduces the use of relational operators in Lua, which is the basic knowledge of LUA learning, and needs friends to refer to the following
The following table lists the relational operators that are supported by all LUA languages. Suppose variable a holds 10 and variable B holds 20:
Example
Try the following example to understand the relational operators provided by all of the LUA programming languages:
The code is as follows:
A = 21
b = 10
if (a = = b)
Then
Print ("line 1-a are equal to B")
Else
Print ("line 1-a isn't equal to B")
End
if (a ~= b)
Then
Print ("line 2-a isn't equal to B")
Else
Print ("line 2-a are equal to B")
End
if (a < b)
Then
Print ("line 3-a is less than B")
Else
Print ("line 3-a are not less than B")
End
if (a > B)
Then
Print ("line 4-a is greater than B")
Else
Print ("line 5-a are not greater than B")
End
--Lets change value of a and B
A = 5
b = 20
if (a <= b)
Then
Print ("line 5-a are either less than or equal to B")
End
if (b >= a)
Then
Print ("line 6-b are either greater than or equal to B")
End
When the above program is established and executed, it produces the following results:
The code is as follows:
Line 1-a isn't equal to B
Line 2-a isn't equal to B
Line 3-a are not less than B
Line 4-a is greater than B
Line 5-a are either less than or equal to B
Line 6-b are either greater than or equal to B