clonefunction
Creates and returns a new function that has the same behaviour as the passed function.
function clonefunction<A..., R...>(function_to_clone: (A...) -> R...): (A...) -> R...
Parameter
func
- The function to clone.
Example
local function DummyFunction()
print("Hello")
end
local ClonedFunction = clonefunction(DummyFunction)
print(debug.info(ClonedFunction, "l")) -- Output: 1
print(debug.info(ClonedFunction, "n")) -- Output: DummyFunction
print(ClonedFunction == DummyFunction) -- Output: false
print(getfenv(ClonedFunction) == getfenv(DummyFunction)) -- Output: true
Last updated