I have NO idea of what it is Used For.
what is ";" used for ????
1 answer
The semicolon ends statements explicitly.
It is optional in almost all cases:
a = 3;
b = 4;
a = b;
function blah(u)
print(u + 9);
if u >= 3 then
blah(u % 3);
end
end
blah(9);
blah(a + b * 7);
The above snippet acts exactly the same if you remove all of the semicolons.
However, there are cases where they are necessary:
a = b;
(c).d();
The first semicolon is required here, because an equivalent statement when you remove the new line (Lua always ignores all space characters) would be this:
a = b(c).d()
That is, function application of c onto the function b.
Some languages require semicolons after all statements, so some Lua programmers do this out of habit or consistency with their own programming styles from other languages. I am one of these people.
You do not have to use semicolons if you do not want to. Personally, I like to use them for the consistency of when they are required in Lua, and also because it's faster for me to think in programming when I use it everywhere.
This discussion is preserved as it was. New answers, comments, and votes are closed.
