Javascript delete keyword deletes a named variable slot from nearest execution environment which it defined. What's the equivalent in Lua?
+4
A:
var = nil
Environments in Lua are tables, and tables cannot contain nil value - assigning nil to a key in a table effectively deletes that key from the table.
Here is a quote from "Programming in Lua":
Like global variables, table fields evaluate to nil if they are not initialized. Also like global variables, you can assign nil to a table field to delete it. That is not a coincidence: Lua stores global variables in ordinary tables
sbk
2010-08-08 08:36:05