table.Count
From GMod Wiki
Function | |
Syntax |
table.Count( Table ) Where is this used? |
Description: | |
Gets the total number of keys in a table - including both integer-keys and string-keys. | |
Returns: | Integer The number of keys in the table. |
Part of Library: | Table |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Table.Count]Table.Count [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
Additional Notes
- This function loops through the entire table every time it is run - be warned this can possibly cause infinite loop protection to kick in on large tables, and is overall inefficient for use in large tables. It is suggested you use table.getn if your table is integer indexed.
- This function does not check to see if the table is nil, and so will return an error if it is.
- If the table is indexed with consecutive integers use the length operator instead. (#table)