Closures

clonefunction

Creates a callable clone of a function while preserving its behavior.

Syntax

clonefunction(func: function): function

Arguments

NameTypeDescription
funcfunctionFunction to clone.

Returns

NameTypeDescription
clonefunctionCloned function reference.

Description

Creates a callable clone of a function while preserving its behavior.

Call it with 1 parameter(s): func. The argument table explains which values are required and which ones only refine the behavior.

It returns clone (function). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = clonefunction(function() end)
print(result)