Garry's Mod Wiki

Garry's Mod Wiki

  any table.GetWinningKey( table inputTable )

Description

Returns a key of the supplied table with the highest number value.

Arguments

1 table inputTable
The table to search in.

Returns

1 any
winningKey

Example

Code that looks up the most favourite fruit from a table where the fruit's name is the key, and it's number value determines how much favourite it is (the higher value, the better).

favouriteFruit = { banana = 4, strawberry = 4, blueberry = 2, apple = 6 } print(table.GetWinningKey(favouriteFruit))
Output: apple

Example

A code that demonstrates a situation where there are two keys with the same value in the supplied table. String keys in the table represent the fruit name, and their number values determine how favourite it is (the higher value, the better).

favouriteFruit = { apple = 1, banana = 7, strawberry = 3, blueberry = 7 } print(table.GetWinningKey(favouriteFruit))
Output: banana

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...