Garry's Mod Wiki

table.FindPrev

any table.FindPrev( table tbl, any value )

Description

We advise against using this. It may be changed or removed in a future update. 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

1 table tbl
Table to search
2 any value
Value to return element before

Returns

1 any
Found element

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

Page Links


Special Pages


Wikis

?

Render Time: 40ms

DB GetPage 5
Generate Html 3
SaveChanges (1) 17
Render Body 0
Render Sidebar 11