Skip to content

CreateFrom

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

Enumerable.createFrom

Creates an Enumerable from an object and a custom iterator factory.

Syntax

values = LuaQ.createFrom(object, iteratorFactory)

Parameters

Parameter Type Description
object any Object passed to the iterator factory.
iteratorFactory function(object) Returns the iterator function, iterator state, and initial control value.

Returns

A new Enumerable using the custom iterator.

Remarks

The factory must return the standard Lua generic-for tuple: nextFunc, state, initialIndex. Use create for source types already recognized by LuaQ.

Example

local playerNames = { "Ada", "Bryn" }
local players = LuaQ.createFrom(playerNames, function(names)
    return ipairs(names)
end)

See also

Create · Functions

Clone this wiki locally