FANDOM


Relational OperatorsEdit

EssentialsEdit

Relational operators are Operators that will use the relationship between the two sides of the expression and return a boolean. There are several operators.

Relational operators list.
== ~= < > <= >=
Equal Not Equal Greater Than Less Than Greater Than Inclusive Less Than Inclusive

SamplesEdit

Sample
The following is a simple use of the operators.

Source:

local a = 5
local b = 6
print(5 < 6)
print(5 > 6)
print(5 == 6)
Output:

true false false



Sample
The following is a simple use of operators in a conditional.

Source:

if 5 < 6 then
       print('5 is less than 6!')
else
       print('What has the world come to?!')
end
Output:

5 is less than 6!


ExtraEdit

The behavior of these operators come from the metatable of the first thing its comparing. However, this behavior cannot be overwritten from Lua.

Sample
Shows how relational operators can not be overwritten.

Source:

debug.setmetatable('', nil)
print('Hello' == 'Hello')
print(('Hello'):sub(1))
Output:

attempt to index a string value

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.