Equality and Inequality Operators

In Lua, you can compare two variables to see if they are equal using the == equality operator. For instance:

-- single = to assign values to variables local Variable1 = "Fred" local Variable2 = "Mary" local Variable3 = "Fred" if (Variable1 == Variable3) then trace("These variables are equal!") end

Below are the comparison operators you can apply to compare variables:

== Equal to

~= Not equal to

< Less than

> Greater than

<= Lesser or equal to

>= Greater or equal to

See if statements for a simple example of applying these comparison operators.

 

Related pages