Originally Posted by Billtopia
myTable = { {unpack( myTable )}, ... }
|
If your original table looks like this:
Code:
myTable = { "one", "two", "three" }
#myTable == 3
And you add the values "four" and "five" on the end:
Code:
tAppend(myTable, "four", "five")
Then your code is actually doing this:
Code:
myTable = { { unpack( { "one", "two", "three" } ) }, "four", "five" }
which simplifies to this:
Code:
myTable = { { "one", "two", "three" }, "four", "five" }
#myTable == 3
You've just created a new table that still only has 3 values, and
another new table containing the original three values. Now imagine what happens after you run that a couple of times:
Code:
myTable = {
{
{
{
{
{
"one",
"two",
"three",
},
"four",
"five",
},
"six",
},
"seven",
"eight",
"nine",
},
"ten",
"eleven",
},
"twelve",
}
Is that really a table structure you'd want to try to work with?
Plus, if you were to do anything like this, you would
never be able to use local references to your table. Add together the ridiculously convoluted structure you see above, the unnecessary overhead of performing a global lookup every time you access your table, and the significant memory waste of creating two new tables and discarding one table every time you append anything, and this is just horribly inefficient and unusable code that you should never even consider using.