AcediaDocumentation

clonefunction

Creates a separate closure with the original function's behavior.

This clones a closure, not an entire graph of tables or captured state. Do not assume captured tables become independent copies.

clonefunction(callback: function): function

Parameters

ParameterTypeDescription
callbackfunctionFunction to clone.

Example

local function original(value) return value + 1 end
local copy = clonefunction(original)
print(copy(5))

Example output

6

On this page