Skip to content
Functions & closuresReference

compareclosures

Compares closure implementations.

Aliasescomparefunctions

Details#

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#

Luau
compareclosures(a: function, b: function): boolean

Parameters#

ParameterTypeDescription
afunctionFirst callable.
bfunctionSecond callable.

Returns#

A boolean; non-function arguments raise an error.

Examples#

Example

Luau
local function f() return 1 end
print(compareclosures(f, f)) -- true
print(compareclosures(f, print)) -- false