summaryrefslogtreecommitdiff
path: root/xmake/core/base/string.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core/base/string.lua')
-rw-r--r--xmake/core/base/string.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/xmake/core/base/string.lua b/xmake/core/base/string.lua
index 7edbbde2d..b3abe36ec 100644
--- a/xmake/core/base/string.lua
+++ b/xmake/core/base/string.lua
@@ -110,6 +110,25 @@ function string:decode()
return (self:gsub("%%(%x%x)", function (w) return string.char(tonumber(w, 16)) end))
end
+-- join array to string with the given separator
+function string.join(items, sep)
+
+ -- join them
+ local str = ""
+ local index = 1
+ local count = #items
+ for _, item in ipairs(items) do
+ str = str .. item
+ if index ~= count and sep ~= nil then
+ str = str .. sep
+ end
+ index = index + 1
+ end
+
+ -- ok?
+ return str
+end
+
-- return module: string
return string