类型 函数 库 table.* 返回值 数组 修订内容 发行版 2024.3703 关键字 table、array 请参见 table.concat()
返回 array 的浅拷贝,即仅返回带有整数键的 array(table)部分。可以将可变数量的其他数组作为可选参数传入。如果某个 array 中有空洞(nil
条目),那么在给定源 array 中的拷贝操作会在空洞之前的最后一个连续项目处停止。
在 Lua 中,函数 table.concat()
等同于 JavaScript 的 array.join()
。因此,以下函数称为 copy()
。
table.copy( t ) table.copy( t, ... )
Array. 元素数组。
可以选择传入的其他数组。
local t1 = {1,3,5,7,9} local t2 = {2,4,6,333} t2[6] = 555 -- create hole local t3 = {11,13,17,19} local c = table.copy( t1, t2, t3 ) -- output: 1, 3, 5, 7, 9, 2, 4, 6, 333, 11, 13, 17, 19 print( table.concat( c, ", " ) )