Quantcast WoWInterface - View Single Post - Tables again...
Thread: Tables again...
View Single Post
12-18-19, 05:43 AM   #2
Kanegasi
A Firelord
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 482
When dealing with sequential numbers as keys, the table is an array. Using table.insert and table.remove shifts the array to accommodate what you inserted or removed. The number 100 (not string) was at index 1, but when you inserted 500 at that position, it moved 100 to index 2. Anything dealing with arrays ignores keys that aren't sequential up from 1, which also means index 0 and negative indexes are also ignored.

The #t operation counts the array part of the table. The last part of your example makes #t == 2, since "a" is ignored.

Last edited by Kanegasi : 12-18-19 at 05:45 AM.
  Reply With Quote