type(var)

Returns the type of a variable.

Parameters

var

A variable to check its type.

Return value

Returns the type of its only argument, as a string. The possible results of this function are "nil", "number", "string", "boolean", "table", "function", "thread", "userdata", "Object" or the name of the last inherited Object.

When using the Luart compatibility interpreter, checking Objects type will return "table".

Example

Polygon = Object { sides = 0 } square = Polygon() square.sides = 4 -- outputs "Polygon" print(type(square)) -- outputs "Object" print(type(Polygon))