Functions & closuresReference
restorefunction
Represents restoration of a function's previous behavior.
Aliases
restorefuncDetails#
Removes the hook installed on target and restores its initial behavior, including after multiple replacements. Pass the target function, not the previous implementation returned by hookfunction. Calling it again is allowed.
Signature#
restorefunction(target: function): booleanParameters#
| Parameter | Type | Description |
|---|---|---|
target | function | The exact function value to inspect or modify. |
Returns#
true when restored; false if target has no saved hook.
Examples#
Example
local function value() return 1 end
hookfunction(value, function() return 2 end)
print(value()) -- 2
print(restorefunction(value)) -- true
print(value()) -- 1
print(restorefunction(value)) -- false