မော်ဂျူး:table/size
ပုံပန်းသွင်ပြင်
Documentation for this module may be created at မော်ဂျူး:table/size/doc
local next = next
local pairs = pairs
--[==[
This returns the size of a key/value pair table. If `raw` is set, then metamethods will be ignored, giving the true table size.
For arrays, it is faster to use `export.length`.]==]
return function(t, raw)
local i, iter, state, init = 0
if raw then
iter, state, init = next, t, nil
else
iter, state, init = pairs(t)
end
for _ in iter, state, init do
i = i + 1
end
return i
end