Repository navigation
IndexOf
Dennis Corvers edited this page Oct 23, 2026
·
1 revision
Returns the 1-based position of the first value equal to a requested item.
position = values:indexOf(item, comparer)| Parameter | Type | Description |
|---|---|---|
item |
any | Value to locate. |
comparer |
function(value, item) (optional) |
Returns true when the values are considered equal. |
The 1-based position of the first match, or -1 if no match is found.
The returned position counts elements in iteration order; it is not necessarily the key used by the source iterator.
local position = LuaQ.from({
{ item = "rune scimitar" },
{ item = "abyssal whip" },
})
:indexOf({ item = "abyssal whip" },
function(entry, wanted) return entry.item == wanted.item end)
-- 2- Home
- Getting Started
-
Functions
- aggregate
- all
- any
- concat
- contains
- count
- create
- createFrom
- deepCopy
- difference
- elementAt
- elementAtOrDefault
- first
- firstOrDefault
- flatMap
- foreach
- groupBy
- groupByResult
- indexOf
- intersect
- ipairs
- last
- lastOrDefault
- map
- max
- min
- pairs
- sequenceEquals
- single
- singleOrDefault
- sort
- sortBy
- sortByDescending
- sortDescending
- sum
- take
- takeWhile
- thenBy
- thenByDecending
- toLookup
- toMap
- toSet
- toTable
- union
- unique
- where
- zip
- Aliases