(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 |