table.GetWinningKey
From GMod Wiki
Function | |
Syntax |
table.GetWinningKey( Table table ) Where is this used? |
Description: | |
Returns the key linked to the highest number. | |
Returns: | nil |
Part of Library: | Table |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Table.GetWinningKey]Table.GetWinningKey [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
Description | This example will print the key associated with the highest number. |
---|---|
Used on | |
Code | local t = {23, 433, 44, 252, 16} print(table.GetWinningKey(t)) |
Output | 2 |
Additional Notes
- The table can only contain numbers.
- If there are multiple keys with the same highest value, the first winning key in the table will be returned.