Syntax
newlclosure(func: function, debugName?: string): functionArguments
| Name | Type | Description |
|---|---|---|
func | function | Function called by the returned Luau closure. |
debugName? | string | Optional debug name for the generated closure. |
Returns
| Name | Type | Description |
|---|---|---|
closure | function | Generated Luau closure that executes return the original function(..) and forwards arguments to the original function. |
Description
Returns a Luau closure that calls the provided function. The first argument must be a function.
Call it with 2 parameter(s): func, debugName. The argument table explains which values are required and which ones only refine the behavior.
It returns closure (function). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Create a Luau closure that calls the original function.
local function add(a, b)
return a + b
end
local wrapped = newlclosure(add, "add")
print(wrapped(2, 3))
print(islclosure(wrapped))