Swift Basics
Bind a constant and print it.
On this page
The concept
let creates a constant. String interpolation evaluates the expression in parentheses and inserts it into the output.
Code example
Swift
let 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
let 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 |
|---|---|---|---|
| Bind an immutable string to name. | name = "Ada" | — | |
| Interpolate name and print the greeting. | name = "Ada" | Hello, Ada |
Behind the scenes
How Swift processes this code
Swift compiles the program; its top-level statements run in source order.