Swift Basics

Bind a constant and print it.

Swift
let name = "Ada"
print("Hello, \(name)")
Output
Hello, Ada

Explanation

let creates a constant. String interpolation evaluates the expression in parentheses and inserts it into the output.

Explore the dry run
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