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
1
local name = "Ada"2
print("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
| Step / line | What happens | State after step | Output 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.