Lua · Course navigation

Lua Basics

Store a local value and print it.

On this page

The concept

local limits the variable to its scope. The .. operator concatenates strings before print writes the result.

Code example

Lua
local name = "Ada"
print("Hello, " .. name)
Output
Hello, Ada

Follow the code

Open the walkthrough to inspect the example one step at a time.

Show guided walkthrough
Guided walkthroughReady
1local name = "Ada"
2print("Hello, " .. name)

Follow the example

Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.

View the complete dry-run table
Prepared trace of the published program. Some rows group repeated iterations.
Step / lineWhat happensState after stepOutput so far
Create a local variable.name = "Ada"
—
Concatenate the two strings and print.name = "Ada"
Hello, Ada

Behind the scenes

How Lua processes this code

The Lua interpreter executes the chunk and resolves local values as it runs.