Last active
July 26, 2018 18:07
-
-
Save indilo53/b1a112f860101f4b11b6cd2f9db7b2a2 to your computer and use it in GitHub Desktop.
LUA - Get correct size of table even if it contains nil values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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