diff options
| author | OpportunityLiu <[email protected]> | 2019-06-19 11:30:06 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-06-19 11:30:06 +0800 |
| commit | d5ad005f6c8a79af48f4c73f0ec87775ab746d0d (patch) | |
| tree | eefdd667a032d9732481b61cff3b4d860853ca8f /xmake/core/base/table.lua | |
| parent | 5c06711d12932c02ab7b64a25135902fabf00675 (diff) | |
improve dump
Diffstat (limited to 'xmake/core/base/table.lua')
| -rw-r--r-- | xmake/core/base/table.lua | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index 2d41e79af..6e7311f68 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -176,22 +176,23 @@ function table.slice(self, first, last, step) return sliced end +local function is_array(table) + local i = 0 + for _ in pairs(table) do + i = i + 1 + if table[i] == nil then return false end + end + return true +end + -- is array? function table.is_array(array) - return type(array) == "table" and array[1] ~= nil + return type(array) == "table" and is_array(array) end -- is dictionary? function table.is_dictionary(dict) - return type(dict) == "table" and dict[1] == nil -end - --- dump table -function table.dump(self, deflate) - local str = string.dump(self, deflate) - if str then - io.write(str) - end + return type(dict) == "table" and not is_array(dict) end -- unwrap object if be only one |
