Skip to content

ElementAt

Dennis Corvers edited this page Oct 23, 2026 · 1 revision

Enumerable:elementAt

Returns the value at a specified 1-based position in an iterable.

Syntax

value = values:elementAt(index)

Parameters

Parameter Type Description
index positive integer 1-based position of the requested value.

Returns

The value at index.

Remarks

An index below 1, a non-integer index, or an index beyond the available values raises an error. For tables iterated with pairs, position follows that iterator's order, which is unspecified.

Example

local selectedPlayer = LuaQ.from({
    { name = "Ada" },
    { name = "Bryn" },
    { name = "Cato" },
})
    :elementAt(2)
-- selectedPlayer.name is "Bryn"

See also

ElementAtOrDefault · First · Functions

Clone this wiki locally