type()

Type Function
Library (globals)
Return value String
Revision Release 2022.3683
Keywords type, datatype

Overview

Returns the type of its argument. Possible results are:

Syntax

type( v )
v (required)

The item whose type is to be determined.

Example

local t = {}
local n = 123
local s = "Hello world!"
local b = true
local function f() return "this is a string"; end

local type_t = type( t )     -- "table"
local type_n = type( n )     -- "number"
local type_s = type( s )     -- "string"
local type_b = type( b )     -- "boolean"
local type_f1 = type( f )    -- "function"
local type_f2 = type( f() )  -- "string"