Lua datatypes

From wikinotes
Revision as of 20:42, 11 February 2024 by Will (talk | contribs) (Created page with "= Documentation = <blockquote> {| class="wikitable" |- | |- |} </blockquote><!-- Documentation --> = Primitives = <blockquote> == Nil == <blockquote> * <code>nil</code> is the absence of a value * <code>nil</code> within a table represents an absent key <syntaxhighlight lang="lua"> nil </syntaxhighlight> </blockquote><!-- Nil --> == Boolean == <blockquote> <syntaxhighlight lang="lua"> true false </syntaxhighlight> </blockquote><!-- Boolean --> == Number == <blockquot...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation

Primitives

Nil

  • nil is the absence of a value
  • nil within a table represents an absent key
nil

Boolean

true
false

Number

A single type number represents both 64-bit integers/floats.

123
123.4

String

An immutable byte-sequence, encoding-agnostic.
All strings must fit iwthin a single integer.

Function

Lua can call native lua, and C functions.

UserData

Represents a block of raw memory.

  • full userdata -- an object with a block of memory managed by lua
  • light userdata -- a C pointer value

Thread

Collections

Table

Associative arrays (keys may be numbers, or any lua value except nil)