Types

Types#

Lua has eight base types and one composite. Values carry their type; variables do not. type(x) returns the type tag as a string.

For the syntax of literals, see Syntax. For operators that act on these values, see Operators.

The catalog#

Type

What it holds

nil

The absence of a value.

boolean

true or false.

number

5.3+ distinguishes integer and float subtypes.

string

Immutable byte sequence.

function

First-class; Lua and C functions are both this type.

table

The one composite type.

userdata

Opaque blob owned by C code.

thread

A coroutine handle.

Pages#

nil

The absence of a value.

nil
boolean

Falsy is only false and nil.

boolean
number

Integer vs float subtypes (5.3+).

number
string

Immutable byte sequences; not Unicode.

string
table

The one composite type; array, map, record.

table
function

First-class values; Lua and C functions.

function
userdata

Opaque host-side blob.

userdata
thread

Coroutine handle.

thread
Casting

tostring / tonumber and the few implicit conversions.

Casting

References#