TableUtil.lua
354 Bytes
function table.arrayToMap(tab)
tab = tab or {}
local len = #tab
local result = {}
for i = 1, len, 2 do
result[tab[i]] = tab[i + 1]
end
return result
end
function table.clear(tab)
for k, _ in pairs(tab) do
tab[k] = nil
end
end
function table.numbers(tab)
local count = 0
for k, _ in pairs(tab) do
count = count + 1
end
return count
end