Reading — step 1 of 5
Learn
~1 min readFirst Steps
Variables in Lua are global by default. Prefer local for everything — global state is almost always a bug magnet.
local name = "Ada"
local age = 36
local pi = 3.14159
Lua has 8 types: nil, boolean, number, string, function, userdata, thread, table. Numbers are 64-bit floats by default (Lua 5.3+ also distinguishes integers internally).
Reassignment is just =. Multiple assignment is built in:
local a, b = 1, 2
a, b = b, a -- swap
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…