Add table.count
This commit is contained in:
parent
bbcc586128
commit
36dba7614e
1 changed files with 11 additions and 0 deletions
|
@ -93,3 +93,14 @@ function table.trim(target)
|
||||||
return v ~= nil
|
return v ~= nil
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Counts the entries of given table.
|
||||||
|
--- @param target table Table to count
|
||||||
|
--- @return number Amount of entries
|
||||||
|
function table.count(target)
|
||||||
|
local count = 0
|
||||||
|
for _ in pairs(target) do
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue