Removing display object from table and then iterating over the table

@divergent,

I was answering @sporkfin above, but I think my answer also addresses your questions.

Summary:

  • I find numeric indexing to be a pain because coding for it is longer and weird.

    • You need to reverse iterate.
    • You MUST deleted entries from the table manually.
  • I don’t find numeric indexing to be more clear than:

    for k,v in pairs(tbl) do – v is the object end

  • I don’t understand your point about not knowing the object reference.  If you are deleting it, you know it.  

@roaminggamer: thank you for clarifying this issue with code examples and all. I really appreciate it!

@roaminggamer  Yes, thanks Ed.  Your grasp of the nuances of Lua and Corona often leads to informative lessons like this.  I appreciate the time you put into this response.  

Don’t give me too much credit.  At the end of the day, while I do have a wide experience in programming and game dev, my deep knowledge is somewhat lacking. 

I think that a real Lua expert would give a better answer and discussion of the costs and benefits.  

Whereas, my response is based more on my preferred usage and game architecture decisions. 

Also, I’m a lazy programmer and will willingly give up a little optimization for easy code writing and legibility.

Nice answer,I think it can be a separate article in coronalabs blog.