Function; getn
Cloaked edited this page Jun 10, 2020
·
1 revision
getn(<tTable>)
(from LUA 4 Manual: 6.1 Basic Functions)
"Returns the 'size' of a table, when seen as a list. If the table has an n field with a numeric value, this value is the 'size' of the table. Otherwise, the 'size' is the largest numerical index with a non-nil value in the table. This function could be defined in Lua:"
function getn (t)
if type(t.n) == "number" then return t.n end
local max = 0
for i, _ in t do
if type(i) == "number" and i>max then max=i end
end
return max
end
<tTable>: the table to get the size of.
LUA 4 Manual: 6.1 Basic Functions
Updated Formatting? Initial
Updated for HWRM? Initial
| Home | Search | Recent Changes | Revision History | About | User Help | Contributor Help | Discussion |