typestar

The program shape in Swift

The smallest Swift: top-level code, print, interpolation.

// A Swift file runs top to bottom; print writes a line.
let club = "Halyard Sailing Club"
print("Race day at \(club)")
print("Boats registered: \(9 + 5)")

How it works

  1. A main.swift-style file runs top to bottom, no main function.
  2. let binds the club's name once.
  3. \(9 + 5) interpolates any expression into the string.

Keywords and builtins used here

The run, in numbers

Lines
4
Characters to type
155
Tokens
28
Three-star pace
75 tpm

At the three-star pace of 75 tokens a minute, this run takes about 22 seconds.

Type this snippet

Step 1 of 3 in Values, step 1 of 27 in Language basics.

Next →

The program shape in other languages