Variables in Lua
-
You must not declare variables, they are created when needed.
-
The type of a variable is not fix, it is defeined by the actual value.
-
Variables are global, if they are not declared local.
-
Values can be thefollowing types:
-
Nil
-
Numbers
-
Literals (Characters, Words...)
-
Boolean (true/false)
-
Table
-
Functionen (Special case of a block)
print( var )
var = "Hello World"
print( var )
The Result:
nil
Hello World
-
Undefined variables are nil
-
Assignment is done with =
print( var1, var2 )
var1, var2 = 1, 4
print( var1, var2 )
The Result:
nil nil
1 4
-
Multiple assignment is possible