2+2=4
if (2 + 2 == 4) then
print("2+2=4. This is correct")
else
print("2+2 is not 4 it is 9. Check your math")
end
COMMUNITY QUESTION
is this script right?
1 answer
Yes, except remember that the first line is not valid Lua.
If it's simply a remark about the code (like it is) then it should be in a comment, specified with two hyphens:
-- 2 + 2 = 4
As a stylistic note, the parenthesis around 2 + 2 == 4 are not required and would usually be omitted.
In addition, it is best practice to tab code to make the "blocks" (the things which are part of if, while, for, function, etc) more obvious:
-- 2+2=4
if 2 + 2 == 4 then
print("2+2=4. This is correct")
else
print("2+2 is not 4 it is 9. Check your math")
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
the parentheses around "2+2=4. This is correct" would also be omitted.
While they can be, I don't see it very commonly and don't consider it good practice since that can only be done with literal strings and tables.