util.table.concat
Shared
Concatenates table elements into a single string
Syntax
local result = util.table.concat(
input,
separator = "",
start_at = 1,
end_at = util.table.len(input)
)Parameters
| Type | Name | Description |
|---|---|---|
table | input | Table to concatenate |
string | separator | String to insert between concatenated elements |
int | start_at | Position where concatenation starts |
int | end_at | Position where concatenation ends |
Returns
| Type | Name | Description |
|---|---|---|
string | result | Concatenated string |
Examples
local t = {"hello", "world", "lua"}
local result = util.table.concat(t)
core.engine.print("info", result) -- 'helloworldlua'local t = {"apple", "banana", "orange"}
local result = util.table.concat(t, ", ")
core.engine.print("info", result) -- 'apple, banana, orange'local words = {"Hello", "World"}
local result = util.table.concat(words, " ")
core.engine.print("info", result) -- 'Hello World'local t = {"a", "b", "c", "d", "e"}
local result = util.table.concat(t, "-", 2, 4)
core.engine.print("info", result) -- 'b-c-d'local data = {"John", "25", "Developer"}
local csv = util.table.concat(data, ",")
core.engine.print("info", csv) -- 'John,25,Developer'local parts = {"home", "user", "documents"}
local path = "/" .. util.table.concat(parts, "/")
core.engine.print("info", path) -- '/home/user/documents'