Skip to content

Contains

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

Enumerable:contains

Determines whether an iterable contains a value equal to the requested item.

Syntax

found = values:contains(item, comparer)

Parameters

Parameter Type Description
item any Value to search for.
comparer function(value, item) (optional) Returns true when the values are considered equal.

Returns

true if a matching value is found; otherwise false.

Remarks

Without a custom comparer, tables are compared recursively as sequences. has is an alias.

Example

local roster = LuaQ.from({
    { accountId = 41, name = "Ada" },
    { accountId = 58, name = "Bryn" },
})

local hasBryn = roster:contains({ accountId = 58, name = "Bryn" },
    function(player, wanted) return player.accountId == wanted.accountId end)
-- true

See also

IndexOf · SequenceEquals · Functions

Clone this wiki locally