diff options
| author | ruki <[email protected]> | 2016-01-23 21:01:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-02-15 19:10:25 +0800 |
| commit | b8b1b5129ddcc0154e701dbac023f19ae1a3bf8c (patch) | |
| tree | 01049fc26145c1fed661984d33cd362bcc2923b4 /xmake/core/base/table.lua | |
| parent | 1dc00c7159433c07412c5081388aafbe93040186 (diff) | |
reimpl template
Diffstat (limited to 'xmake/core/base/table.lua')
| -rw-r--r-- | xmake/core/base/table.lua | 40 |
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 |
