Swift · Course navigation

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
1let 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
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.