Corona tip: Is display.remove() better than object:removeSelf()?

January 8, 2013 at 3:32pm

Is display.remove() better than object:removeSelf()?  

 

display.remove is the same as writing:

 

if object and object.removeSelf then   

   object:removeSelf()

end

 

So you're saving a couple of lines of code writing:

 

display.remove(object)

 

By using display.remove(object) you are saving a couple of lines of code, which add up over a project. It's too easy to not check the existence of the object before trying to remove it and this call helps you. If you're diligent and don't mind checking your own objects, then there isn't much of a difference.