==
OperatorThe ==
operator is the operator for comparing equivalent values.
val1 == val2
- if val1
is equivalent to val2
.
local val1 = 4 local val2 = 2 * 2 if val1 == val2 then print('Equivalent!') end
The above code would print Equivalent! because val1 is equivalent to val2.
~=
OperatorThe ~=
operator is the comparing non-equivalent values! The exact opposite of ==
.
val1 ~= val2
- if val1 is not equivalent to val2.
local val1 = 4 local val2 = 1 if val1 ~= val2 then print('Not Equivalent!') end
The above code would print Not Equivalent! because val1 is not equivalent to val2.
Both ==
and ~=
are used in if
or repeat - until
functions. ==
means 'is equal to', and ~=
means 'is NOT equal to'.
Example:
if Value == true then --Code elseif Value ~= true then --Other code end