Closures

islclosure

Returns whether the provided function is a Lua closure.

Syntax

islclosure(func: function): boolean
Aliases isluaclosure

Arguments

NameTypeDescription
funcfunctionFunction to test.

Returns

NameTypeDescription
isLClosurebooleantrue when the function is a Lua closure; otherwise false.

Description

Returns whether the provided function is a Lua closure. The argument must be a function; passing a non-function raises a type error. isluaclosure is an alias.

Call it with 1 parameter(s): func. The argument table explains which values are required and which ones only refine the behavior.

It returns isLClosure (boolean). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Check whether a function is an L closure.

local function target()
end

print(islclosure(target))