Having a bit of trouble here hoped someone could help me. This is mainly a Lua question I believe and doesn’t directly pertain to Corona but nevertheless it is for a Corona project so here goes…
[lua] for i = 1, #myTable do
local tableItem = myTable[i]
if someConditionIsMet then
–Remove the item from the array
table.remove (myTable, i)
end
end[/lua]
The issue I am getting is a runtime error basically saying that tableItem is nil, I believe this is because when I remove the item from the table, I am still iterating over the original table’s length. So this is causing an error because my new table may not have that many items left in it.
Is there a way to loop over a table that has a variable length (i.e. removing and inserting items into it within the loop)?
Thank you for any assistance you can provide. [import]uid: 10747 topic_id: 3723 reply_id: 303723[/import]