table.maxn()

Type Function
Library table.*
Return value Number
Revision 2017.3060
Keywords table, array

Overview

Returns the largest positive numerical index of the given table, or zero if the table has no positive numerical indices. To do its job, this function does a linear traversal of the whole table.

Syntax

table.maxn( t )
t (required)

Array. The array to traverse.

Example

local t = { 1,1,2,3,5,8,13 }
print( table.maxn(t) )   --> 7