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
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