Syntax
comparefunctions(func1: function, func2: function): booleanAliases
comparefunctionArguments
| Name | Type | Description |
|---|---|---|
func1 | function | First function value to convert with function identity. |
func2 | function | Second function value to convert with function identity. |
Returns
| Name | Type | Description |
|---|---|---|
equal | boolean | true when both function values resolve to the same function identity; otherwise false. |
Description
Compares two function values by their function identity. Both arguments must be functions. The function returns the boolean result of function identity(L, 1) == function identity(L, 2). It does not compare function bytecode, source, behavior, hashes, upvalues, or newcclosure mappings. comparefunction is an alias for the same function.
Call it with 2 parameter(s): func1, func2. The argument table explains which values are required and which ones only refine the behavior.
It returns equal (boolean). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Compare two functions by their function identity.
local function sample()
return "ok"
end
local same = comparefunctions(sample, sample)
print(same)