Type Function Object Runtime Library none Return value none Revision 2017.3060 Keywords runtime, setCheckGlobals
Allows the usage of global variables to be flagged. Because Lua automatically assumes that any variable it doesn't recognize is a global variable, typos in variable names can lead to unexpected behavior. For example, accessing a variable that has never been set will yield a value of nil
.
Essentially, the usage of global variables in Lua code should be avoided. Using this function to enable the check for global variables will flag all such instances so they can be fixed.
This setting is only supported in the Corona Simulator.
Runtime:setCheckGlobals( enabled )
Boolean. Enable or disable checking for the usage of global variables.
-- Warn about the use of global variables Runtime:setCheckGlobals( true )