Whitespace
Whitespace is a type of character used to make code easier to read. Spaces, tabs, and newlines are considered whitespace characters. It is ignored (in most cases) by the Lua compiler.
General Examples
Spaces
Without (most) whitespace:
number=476
disgusting_food="fried chicken"
With whitespace:
number = 476
disgusting_food = "fried chicken"
Tabs
Tabs are used to organize scripts after:
do
then
repeat
Without tabs:
if 1 == 1 then
while true do
print("One is equal to one!")
wait()
end
else
print("OMGHAX.")
print("A paradox is coming!")
end
With tabs:
if 1 == 1 then
while true do
print("One is equal to one!")
wait()
end
else
print("OMGHAX.")
print("A paradox is coming!")
end
Newlines
Lua will also ignore new lines in some parts of your code. However, this can lead to problems.
Without newlines:
print("test") --> test
With newlines:
print(
"test"
) --> test
When whitespace isn't ignored
If you put extra whitespace in a string, the whitespace won't be ignored.
print("Hello world!") --> Hello world!
print("Hello world!") --> "Hello world!"
print("Hello world!" == "Hello world!") --> false
Ambiguities
Because Lua ignores newlines, this can lead to certain problems because the compiler is unsure about what you're trying to do, so it will warn you when you're about to run into trouble.
For a full description and example, see the error page about it.