diff options
| author | ruki <[email protected]> | 2016-06-15 11:17:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-06-15 11:17:26 +0800 |
| commit | cfd9db015cbb79b047280d0acfad5950530d4158 (patch) | |
| tree | 768ee463a5bd63e26e1561c8ea24b27221e5a7ad /xmake/core/base/string.lua | |
| parent | d960300a20f47a9787d4881dd4e7dd5d2f6150d9 (diff) | |
add bindings for option
Diffstat (limited to 'xmake/core/base/string.lua')
| -rw-r--r-- | xmake/core/base/string.lua | 19 |
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 |
