Skip to content

Instantly share code, notes, and snippets.

@indilo53
Last active July 26, 2018 18:07
Show Gist options
  • Save indilo53/b1a112f860101f4b11b6cd2f9db7b2a2 to your computer and use it in GitHub Desktop.
Save indilo53/b1a112f860101f4b11b6cd2f9db7b2a2 to your computer and use it in GitHub Desktop.
LUA - Get correct size of table even if it contains nil values
function table.sizeOf(t)
local keys = {}
for k,v in pairs(t) do
table.insert(keys, tonumber(k))
end
table.sort(keys, function(a,b) return a < b end)
return keys[#keys]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment