Volt

islclosure

Checks if a function is a Luau closure.

Syntax

islclosure(func: function) -> boolean

Parameters

ParameterTypeDescription
funcfunctionThe function to check

Returns

TypeDescription
booleantrue if the function is a Luau closure, false otherwise

Description

islclosure returns whether the given function is written in Luau rather than C/C++. Luau closures include user-defined functions and script functions.

Example

-- User-defined functions are Luau closures
local function myFunc()
    return "hello"
end
print(islclosure(myFunc)) -- true

-- Built-in functions are NOT Luau closures
print(islclosure(print)) -- false
print(islclosure(type)) -- false

-- Wrapped functions are NOT Luau closures
local wrapped = newcclosure(myFunc)
print(islclosure(wrapped)) -- false

Relationship with iscclosure

islclosure is the logical opposite of iscclosure:

local function test() end

print(islclosure(test)) -- true
print(iscclosure(test)) -- false

print(islclosure(test) == not iscclosure(test)) -- true

On this page