July 2018
Beginner
202 pages
5h 42m
English
A nil value represents the absence of data. If you try to access a variable that has not been created yet, its value will be nil. If you are done using a variable, you should assign it to be nil. This code first prints nil because nothing is assigned to the variable foo. Then, the string bar is assigned, and after this the code prints bar. Finally, nil is assigned back to the variable. The last time the variable is printed, it will print nil again:
print (foo) -- will print: nilfoo = "bar"print (foo) -- will print: barfoo = nilprint (foo) -- will print: nil