table.FindPrev

From Garry's Mod
Jump to: navigation, search
 table.FindPrev( )

Contents

Description

This feature is deprecated.
You should avoid using it as it may be removed in a future version.

Instead, iterate your table with ipairs, storing the previous value and checking for the target. Non-numerically indexed tables are not ordered.

Returns the value positioned before the supplied value in a table. If it isn't found then the last element in the table is returned

Arguments

table tbl

Table to search

Arguments

any value

Value to return element before

Returns

any

Found element

Examples

Example

Print the previous item the value "b" of the table

local tbl = {"a", "b", "c"}

print(table.FindPrev(tbl, "b"))

Output:

a in console
Personal tools
Navigation