Empty variables and Special variables

What if we try to use (e.g. print) variable without putting anything into it first? Well, just try:

print(x)

Running such code in the program area below, we'll see output nil. In Lua this is the secret word meaning empty variable. (some other languages will immediately complain the variable was never assigned to)

Let's use this new knowledge for small experiment: what if we write variable name in different manner - once in small letters, and once in capital letters. Try it:

x = 314
print(x, X)

Note the first x inside print is small, the second is capital. The output is like 314 nil. So now we know variable names (and any keywords) in Lua are case-sensitive (it is similar for most languages, but not all).

For exercise try to print out a variable with fancy name _VERSION (note it is all capital letters) without defining it. You should see it doesn't give nil. Obviously it is a predefined variable useful to check the version of language interpreter.