Home  Contents

table.reverseLookup

Table Core4 Lua Commands

SYNOPSIS

key = table.reverseLookup(tbl, value)

DESCRIPTION

Does a linear search of tbl for an entry with the value value. Returns the key of the first value found.

RETURN VALUE

Returns the key of the first value that was found, or nil if no value matches value.

NOTES

This function does a linear walk of the table. For big tables this can be slow. Think about restructuring your table design if you need to use this function often.

If the table contains more than one entry that matches value, only one key is returned. It is undefined which of the multiple keys is returned.