类型 函数 库 table.* 返回值 字符串 修订 发行版 2024.3703 关键字 table 数组 另请参见 table.insert()
将表中的元素连接在一起以形成一个字符串。每个元素都必须能够强制转换为字符串。可以指定一个分隔符,该分隔符置于连接的元素之间。
table.concat( t ) table.concat( t, sep ) table.concat( t, sep, i ) table.concat( t, sep, i, j )
数组。其中所有元素都是字符串或数字的数组。
字符串。要在连接的表值之间插入的字符串。默认值为空字符串。
数字。要连接的第一个表索引。默认值为 1。
数字。要连接的最后一个表索引。默认值为数组 t
的长度。如果 i 大于 j,则返回空字符串。
local t = { 1, 2, "three", 4, "five" } print( table.concat(t) ) --> 12three4five print( table.concat(t, ", ") ) --> 1, 2, three, 4, five print( table.concat(t, ", ", 2, 4) ) --> 2, three, 4