ReferenceClosures

comparefunction

Checks whether two functions are the same underlying function, even when one is a copy.

Syntax

comparefunction(a: function, b: function) -> boolean

Also available as

comparefunctions

Parameters

ParameterTypeDescription
afunctionThe first function.
bfunctionThe second function.

Returns

TypeDescription
booleantrue when both values run the same code.

Description

== is only true for the very same value. comparefunction also treats a clonefunction copy as equal to its source, because both run the same prototype or the same native code.

Example

local function f() end
local g = clonefunction(f)

print(f == g)
print(comparefunction(f, g))
print(comparefunction(f, print))

These are Game executor contracts. Check build requirements and session lifetimes before using them.