0

# == and = and spacing

I read this. I did not understand what it meant. Could anyone expand on this. + What is the difference between = and ==.

"not is simply a negation of a condition. It will be inverted. True becomes false and false becomes true. e.g. (5 == 5) the result is true. At the condition not (5==5) we get false as result. "

6
jobro13 980
10 years ago

You use the = character to set variables. == basically means "check if equal". This will "return" either true or false.

a = 5 -- Set a variable
-- b == 5 -> This is not correct and will result in a syntax error
b = 5
a = (b == 5) -- This is correct though. It will set a to the result of (b==5).
print(a) -- prints true, as b equals 5
b = 6
print(b == 5) -- prints false, as b equals 6.
--You can find these statements too in "if - then constructions"
if b == 5 then
print("B equals 5!")
else
print("B does not equal 5!")
end

3
Thx bro. does spacing change anything. liek 5==6 5 == 6 ConnorVIII 448 — 10y
3
No, spacing does not change anything at all :) You could also write "a = 5" if you would like. jobro13 980 — 10y