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

Enumerable:any

Determines whether an iterable contains any values, or any values that satisfy a predicate.

Syntax

exists = values:any(predicate)

Parameters

Parameter Type Description
predicate function(value, sourceKey) (optional) Returns true for a matching value.

Returns

true when the iterable is non-empty if no predicate is supplied, or when at least one predicate call returns exactly true. Otherwise false.

Remarks

The predicate receives the source iterator key. any stops once it finds a match.

Example

local hasLowSupplies = LuaQ.from({
    { name = "Ada", potions = 8 },
    { name = "Bryn", potions = 2 },
})
    :any(function(player) return player.potions < 3 end)
-- true

See also

All · Count · Functions

Clone this wiki locally