Garry's Mod Wiki

Garry's Mod Wiki

  number table.maxn( table tbl )

Description

Returns the highest numerical key.

Arguments

1 table tbl
The table to search.

Returns

1 number
The highest numerical key.

Example

Demonstrates how this differs from the # operator.

local tbl = {"One", "Two", [6] = "Six", [42] = "Answer to life, the universe, and everything"} PrintTable(tbl) print("\n" .. #tbl) print(table.maxn(tbl))
Output:
1 = One 2 = Two 6 = Six 42 = Answer to life, the universe, and everything 2 42

Whereas the length operator (#) returns the highest sequential index, this returns the value of the highest numeric index.

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...