table.maxn
From GMod Wiki
Function | |
Syntax |
table.maxn( Table ) Where is this used? |
Description: | |
Returns the highest positive numerical index. Returns 0 if there are no numerical indexes (or only negative indexes) in the table. See examples for a simplified explanation. | |
Returns: | Number |
Part of Library: | Table |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Table.maxn]Table.maxn [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
Additional Notes
- This function generally isn't reliable for getting the number of things contained in a table. Use table.getn if you're looking to count how many things are in a table if you know it's sorted in a "regular fashion" (packed from 1 to n; ex: 1,2,3,4,5,6,7). Use table.Count to count how many things are in a table if the table is sorted irregularly.
- This is different to table.getn as it fetches the largest numerical index of a table, instead of the largest consecutive numerical index from 1.