From cfd9db015cbb79b047280d0acfad5950530d4158 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 15 Jun 2016 11:17:26 +0800 Subject: add bindings for option --- xmake/core/base/string.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'xmake/core/base/string.lua') 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 -- cgit v1.3.1