Jump to content

Clear Table


'LinKin

Recommended Posts

Hello,

I've a table (like a matrice of 2 columns)

I store the online players' name and element (table.insert(myTable,{playerName, theElement}))

But then, how can I clear it?

if I use a loop and do table.remove(myTable, i) it doesn't work. I mean something crashes there and the table is not really cleared but all messed up.

I'm currently doing myTable = { }

But is that a good way to do it? I want to save memory space.

So how can I clear the table properly?

Link to comment

myTable = {} is the same as myTable = nil. The garbage collector at the next cycle will clear the memory used by the table in both cases. The only difference is that if you used nil, and want to use the variable again as a table you have to declare it again like myTable = {}.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...