I’ve been trying to wrap my head around what happens when you set an object passed as a parameter to nil.
So I did a test…
local function removeObject(obj) obj.test = 2 obj = nil end local photoPicker = display.newGroup() -- any display object photoPicker.test = 1 removeObject(photoPicker) if (photoPicker == nil) then print("PhotoPicker is nil") else print("PhotoPicker is not nil") print("Test: ", photoPicker.test) end
I’m surprised that after calling removeObject, photoPicker is not nil, but the test field was changed.
Why is that? I assume whatever that reason, that’s probably why display.remove doesn’t automatically nil the object. (Because I was wondering, why doesn’t display.remove automatically do that?)
Dave