summaryrefslogtreecommitdiff
path: root/xmake/core/base/table.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-08-08 23:37:41 +0800
committerruki <[email protected]>2017-08-08 23:37:41 +0800
commit24293af542a3167b616085317a4bfaac8e653a31 (patch)
tree706a00c565ef034bcfbb0c6ef8b595dd35d3052d /xmake/core/base/table.lua
parentd0615e6499637a780cefe2d69f61cc1457929120 (diff)
add table.append
Diffstat (limited to 'xmake/core/base/table.lua')
-rw-r--r--xmake/core/base/table.lua28
1 files changed, 10 insertions, 18 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 023166f69..db06f094f 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -27,11 +27,6 @@ local table = table or {}
-- clear the table
function table.clear(self)
-
- -- check
- assert(self and type(self) == "table")
-
- -- clear it
for k in next, self do
rawset(self, k, nil)
end
@@ -40,10 +35,8 @@ end
-- join all objects and tables
function table.join(...)
- -- done
- local args = {...}
local result = {}
- for _, t in ipairs(args) do
+ for _, t in ipairs({...}) do
if type(t) == "table" then
for k, v in pairs(t) do
if type(k) == "number" then table.insert(result, v)
@@ -53,20 +46,13 @@ function table.join(...)
table.insert(result, t)
end
end
-
- -- ok?
return result
end
-- join all objects and tables to self
function table.join2(self, ...)
- -- check
- assert(self and type(self) == "table")
-
- -- done
- local args = {...}
- for _, t in ipairs(args) do
+ for _, t in ipairs({...}) do
if type(t) == "table" then
for k, v in pairs(t) do
if type(k) == "number" then table.insert(self, v)
@@ -76,11 +62,17 @@ function table.join2(self, ...)
table.insert(self, t)
end
end
-
- -- ok?
return self
end
+-- append all objects to array
+function table.append(array, ...)
+ for _, value in ipairs({...}) do
+ table.insert(array, value)
+ end
+ return array
+end
+
-- copy the table to self
function table.copy(copied)