(1)可以用任意類型的值來作數組的索引,但這個值不能是 nil;
(2)table 是不固定大小的,可根據需要自由擴容;
(3)Table 的操作:
操作 | 使用 |
---|---|
連接 | table.concat (table [, sep [, start [, end]]]); |
插入 |
table.insert (table, [pos,] value); |
刪除 | table.remove (table [, pos]); |
排序 |
(1)table.sort (table [, comp]); (2)默認升序排序; |
賦值 |
local a_table = { 1 , 2 , 3 }; local b_table = a_table; a_table = nil; print( b_table[1] ) -- 1 |