COUNT
count( table )
table | the variable name of the table you want to count |
This function will return the highest number key in a table. To accurately return the total count, the table must be numbered and without any gaps.
Example
We can create a table that is a list of color strings first and add values immediately like this:
colors = { "red", "blue", "pink", "yellow" }
Colors | |
1 | "red" |
2 | "blue" |
3 | "pink" |
4 | "yellow" |
Then if we want to count the number of entries in the table, we can do this:
count( colors ) --returns 4
Shorthand
#colors --returns 4
Images in this Guide by NerdyTeachers is licensed under CC BY-SA 4.0
1208
5 May 2023