Added a short to tcount in case the specified table is an array.
m (catfix) |
(Added a short to tcount in case the specified table is an array.) |
||
| Line 71: | Line 71: | ||
-- tcount: count table members even if they're not indexed by numbers | -- tcount: count table members even if they're not indexed by numbers | ||
function ''<PREFIX>''_tcount(tab) | function ''<PREFIX>''_tcount(tab) | ||
local n=0 | local n = #tab | ||
if (n == 0) then | |||
for _ in pairs(tab) do | |||
n = n + 1 | |||
end | |||
end | end | ||
return n | return n | ||
end | end | ||
| Line 92: | Line 94: | ||
__NOTOC__ | __NOTOC__ | ||
[[Category:User defined functions]] | [[Category:User defined functions]] | ||