Thread: Tables again...
View Single Post
12-20-19, 02:04 AM   #6
doofus
A Chromatic Dragonspawn
Join Date: Feb 2018
Posts: 158
I do not think this is right. t[1] is not an integer index, there is NO "position 1" in the table, unless, and only if, I define k[n], where n is an integer, either by k[n]=value or by table.insert(t,n,value).

Otherwise there is no "position 1" in the table. eg

t = { };
t["hello"] = "goodbye";

t does not have position 1.

table.remove(t,1);

Does not do anything, there is no "position 1" and t["hello"], even though the only element in the table, is NOT considered to be position 1, or ANY position at all.

t[2] = "day"

Now t does have a position 1.

table.insert(t,1,"night")

now we have position 1 = "night" and position 2 = "day"

All the while t["hello"] has not been affected, it is like independent...

The way to understand this is that a table has two types of keys and accessing mechanisms, string keys and integer keys. Integer key/value pairs can be affected by table.insert / remove but string key/value pairs are not.

This is what I have fathomed by running tests all in between wiping in M+10 because we do not know the strats...
  Reply With Quote