There are very few sections we will explore the possibility of making use of a semicolon in Lua. Majority of the code doesn’t require it, while there are some cases where we might need them.
Let’s consider a case where the use of semicolon seems necessary. Consider the example shown below −
local a,b=10,20 print(a+b)
The above statement in Lua is perfectly valid and it works like a charm.
What if we change the code above and put it in the same line? Would it still be a valid Lua code? Let’s try it out. Consider the code shown below −
local a,b =10,20 print(a+b)
The above code in Lua will still work as expected but it doesn’t seem very user friendly and that’s where the use of a semicolon will come in handy.
Consider the example shown below −
local a,b =10,20;print(a+b)