newcclosure
Wraps a Lua function as a C closure.
Syntax
newcclosure(fn: function) -> function
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | function | The function or callback to use. |
Returns
| Type | Description |
|---|---|
function | The returned function. |
Description
newcclosure is part of the Closures library. Closure helpers operate on live Luau function objects. Hooks redirect future calls through the replacement closure and return the previous implementation.
Each call creates or returns a fresh object or value that you can store and pass to other functions.
Example
local fn = newcclosure(function(value)
return value + 1
end)
print(fn(1))
Notes
- Closure operations act on live Luau function objects; installed hooks remain active until restored.