I have read the great tutorial by Jonathan Beebe about properly removing variables, but there is one thing I still don’t understand. Does it make any difference from a performance/cleanup standpoint if I declare a local variable (holding something other than a display object, like an alpha numerical value) inside or outside a function?
In the tutorial it says:
“Local variables get cleaned up automatically at the end of their block of code. What that does not mean, however, is that if you create an object within a small, isolated block of code, that the object will be removed at the end of function execution. Actually, this is a pretty bad situation as the object will remain, but the local variable will be cleared away and you’ll have no way to access the object (which hinders you from being able to remove it later on).”
I that also true for variables NOT holding a display object? In other words, will the variable myAlphaNum also be “created and abandoned” in the function below?
local function create\_and\_abandon() local outcast = display.newImage( "image.png" ) local myAlphaNum = "AA23" outcast.x, outcast.y = 160, 240 end