As of right now I am using table.insert(table, position in table, item) to add items to a table, and using a for loop to add things from another table to it, but I also have to add a counter to it so that for the position in the table it is always one more than the last. This seems tedious to me (even if it is only a couple lines) so I was wondering if there was anything similar to appendItem() from javascript that I just don't know about. I also couldn't find anything about it in the lua documentation. Thanks for any answers!
COMMUNITY QUESTION
[ANSWERED] Is there an easier way to append items to a list?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
you could get the length of the table and add 1 to it and that would solve the issue of repetition you can access the table's length by using #(tablenamehere) and add 1 to it in parentheses.
table.Insert(MyTable, #MyTable + 1, item)
@Mr_Pure thanks, I might use that. I'll mark this question as answered. Would upvote but can't.
If you omit the position argument, it defaults to the index after the end of the list.
@RayCurse Ah that's more straightforward than I figured, thanks