summaryrefslogtreecommitdiff
path: root/xmake/core/base/table.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-01-23 21:01:42 +0800
committerruki <[email protected]>2016-02-15 19:10:25 +0800
commitb8b1b5129ddcc0154e701dbac023f19ae1a3bf8c (patch)
tree01049fc26145c1fed661984d33cd362bcc2923b4 /xmake/core/base/table.lua
parent1dc00c7159433c07412c5081388aafbe93040186 (diff)
reimpl template
Diffstat (limited to 'xmake/core/base/table.lua')
-rw-r--r--xmake/core/base/table.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 52b726412..dfc5def8b 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -95,5 +95,45 @@ function table.copy2(self, copied)
end
+-- is array?
+function table.is_array(self)
+
+ -- not table?
+ if type(self) ~= "table" then
+ return false
+ end
+
+ -- is array?
+ for k, v in pairs(self) do
+ if type(k) == "number" then
+ return true
+ end
+ break
+ end
+
+ -- dictionary
+ return false
+end
+
+-- is dictionary?
+function table.is_dictionary(self)
+
+ -- not table?
+ if type(self) ~= "table" then
+ return false
+ end
+
+ -- is dictionary?
+ for k, v in pairs(self) do
+ if type(k) == "string" then
+ return true
+ end
+ break
+ end
+
+ -- array
+ return false
+end
+
-- return module: table
return table