From ComputerCraft
Jump to: navigation, search

Nil is a special value denoting the absence of a value, and has the type nil.[1] It is often returned by functions to indicate an error condition, usually along with an error message as the second return value. Such functions include loadfile and loadstring.[2] It is good practice to check if a variable is nil before using it, to prevent errors such as "attempt to call nil" or "attempt to index ? (a nil value)", which will happen when a nil value is used regardless. In the context of tables, setting the value of a key to nil will effectively delete the key.[1]


  1. 1.0 1.1 Ierusalimschy, Roberto (March 2006). Programming in Lua. p. 29. ISBN 8590379825. 
  2. Ierusalimschy, Roberto (March 2006). Programming in Lua. p. 83. ISBN 8590379825.