所以我試圖測試table.insert在已經有一個條目時如何工作,並且我發現如果在向該條目之前的表中插入任何內容之前存在4的倍數的條目,弄亂爲什麼4的倍數搞砸了table.insert()?
t = {}
t[4] = "this works"
for i = 1,9 do
table.insert(t,i)
end
for i = 1,#t do
print(t[i])
end
print("total: "..#t)
輸出:
1
2
nil
this works
3
4
5
6
7
8
9
total: 11
對於t [3]和t [0,1],可能有[Lua表的有趣現象]重複(http://stackoverflow.com/questions/16076364/an-interesting-phenomenon-of-luas-table) – hjpotter92