Reference › Function reference › Functions

Functions.collections.multiinsert

public

Call as

Functions.collections.multiinsert(t, values)

Record it as a dependency named Functions.collections.multiinsert (accepting the completion does this), then call it by that name.

What it does

Insert each value visited by ipairs at its corresponding leading index in the destination array. Existing entries shift after the inserted prefix; traversal stops at the first missing source index.

Arguments

NameTypeWhat it does
ttableDestination array modified in place.
valuestableSource array whose ipairs prefix is inserted without copying nested values.

Returns

1...No return values. The destination array is modified in place.

Editions

Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.

It reads no game API directly.

Example

local order = { "Rend", "Overpower" }
Functions.collections.multiinsert(order, { "Execute", "Mortal Strike" })
-- order is now Execute, Mortal Strike, Rend, Overpower
return order[1] == "Execute"

Source

Functions/collections.lua, line 99. Read only in game; Duplicate makes an editable copy.

Functions.collections.multiinsert(t, values)
    for i,v in ipairs(values) do
	    table.insert(t, i, v)
    end

Back to Function reference