Lua hash table length

This article is tagged with: Lua hash table length and lua

lua hash table length

-- there is no way to achieve this other than to create your own function.
-- using #table ("#" is shorthand for table.getn(table)) won't factor in key names.
function table_length(t)
local z = 0
for i,v in pairs(t) do z = z + 1 end
return z
end

This article is tagged with: Lua hash table length and lua