Skip to content
Dennis Corvers edited this page Oct 23, 2026 · 2 revisions

Enumerable:zip

Combines corresponding values from two iterables using an optional result selector.

Syntax

zipped = source:zip(second, resultSelector)

Parameters

Parameter Type Description
second iterable The iterable paired with the source.
resultSelector function(valueA, valueB) (optional) Produces one output value from each pair.

Returns

A deferred Enumerable that ends as soon as either input is exhausted. Without a result selector, each output is a two-element table { valueA, valueB }.

Remarks

The result selector receives values from the two inputs, not their source keys.

Example

local attendance = LuaQ.from({
    { name = "Ada" },
    { name = "Bryn" },
})
    :zip({ true, false }, function(player, checkedIn)
        return { name = player.name, checkedIn = checkedIn }
    end)
    :toTable()
-- { { name = "Ada", checkedIn = true }, { name = "Bryn", checkedIn = false } }

See also

Concat · Map · Functions

Clone this wiki locally