Functions & closuresReference
compareclosures
Compares closure implementations.
Aliases
comparefunctionsDetails#
Compares underlying code identity: Luau closures match when they share a prototype; C closures match when they share a native entry point. This is not equality of captured values or proof of equivalent results. Mixed C/Luau inputs return false. comparefunctions is an alias.
Signature#
compareclosures(a: function, b: function): booleanParameters#
| Parameter | Type | Description |
|---|---|---|
a | function | First callable. |
b | function | Second callable. |
Returns#
A boolean; non-function arguments raise an error.
Examples#
Example
local function f() return 1 end
print(compareclosures(f, f)) -- true
print(compareclosures(f, print)) -- false