Setting object to nil in a function

Hello,

 

I created a convenience function to remove display objects:

function removeDisplayObject(obj)     display.remove(obj)     obj = nil end

However, when I call the function on a display object…

removeDisplayObject(a) if (a == nil) then print "object is nil" else print "object is not nil" end 

… the display object passed to the function isn’t being set to nil. Anyone know why? My goal is to properly remove a display object with a single code statement.

 

Thanks!

John

That code looks fine to me, in fact it’s how I remove objects in my own projects.

There must be something else happening that’s causing a problem.

Closing, double post

That code looks fine to me, in fact it’s how I remove objects in my own projects.

There must be something else happening that’s causing a problem.

Closing, double post