Programming · course 22 of 105
Swift Before the Screens
Read small Swift programs and say exactly what they print, that they won’t compile, or that they crash: numbers, strings, arrays, dictionaries, switch, optionals and functions.
Not on sale yet. When sales open: $4.99 for this course, paid once, or every course for $9.99 a month. Prices
Preview
What it teaches
Reading small Swift programs and saying exactly what they print, or that they won’t compile, or that they stop while running. Int and Double arithmetic (7 / 2 is 3, -9 % 4 is -1), constants and variables (a let can’t be changed), string interpolation, the type Swift infers, and Int("42") printing as Optional(42); arrays (append, count, indexes from 0, sorted(), an index past the end), dictionary lookups (an optional: Optional(31) or nil), for loops over 1...3 against 0..<3, switch (it must be exhaustive and it doesn’t fall through); optionals (if let, guard let, ??, optional chaining, force-unwrapping a nil) and functions (argument labels, _, default values), with two write-the-function items. The AI asks 3 questions, places you, shows a short card per module (quoted from the Swift book, The Swift Programming Language, plus examples really run on Swift 6.0.3), then gives you one small program at a time and names the slip when it’s one of the common ones.
It is a reading-and-predicting course with two write-the-function items; it can’t debug your own program.
Not in this course: app screens, SwiftUI, UIKit, Xcode and iOS frameworks; concurrency (async / await, actors); classes, structs, enums and protocols; closures, try / catch, Set, tuples, Foundation.
How long
38 items (10 concept questions and 28 programs). About 12-35 rounds for a confident student up to about 50-65 for a beginner, plus a 12-item final: 1-3 sessions (estimate, not timed with a real student). The tutor gives a one-line save code at the end of each session.
The modules
4 modules, drilled one item at a time.
- M0
The words
Swift’s words as the Swift book states them: constants and variables, type inference, string interpolation, optionals and nil, arrays, dictionaries, ranges
- M1
Values, types and text
Int and Double arithmetic, constants, string interpolation, the type Swift infers, and turning text into an Int
- M2
Collections, ranges and switch
Arrays, dictionary lookups, for loops over ranges, and switch
- M3
Optionals and functions
Optionals (if let, guard let, ??, optional chaining, force-unwrapping) and functions (argument labels, default values), with two write-the-function items
Before it teaches, it asks
- 1What do you want Swift for (iOS apps, a class, a job, curiosity), and have you written code before in any language?
- 2What does this print? If it won’t compile, say so. If it stops while running, give the lines it printed first and say it stopped.let apples = 7let people = 2print(apples / people)
- 3What does this print? If it won’t compile, say so. If it stops while running, give the lines it printed first and say it stopped.var nums = [3, 1, 2]nums.append(5)print(nums.count)print(nums[1])
What’s exact, and what isn’t
Show
Straight from the course’s own notes.
- Keys are checked by running
- Every key that is program output is what the program really printed when a script compiled it with swiftc and ran it on Apple Swift 6.0.3 (swift --version: swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1), target arm64-apple-macosx15.0). Compile error is checked by swiftc really refusing the code, and the working quotes the compiler’s first error message. Runtime error is checked by the program really starting, printing the lines before it and then stopping with a Fatal error: message, which the working quotes. To keep the lines printed before a crash, the runner makes the output line-buffered, as a terminal does. Each of the 28 programs was run twice, once as a function in one batch and once as its own top-level file, and gave the same key both times. Each key is also written by hand first and must match the run, or the script fails. Not run on any other Swift version.
- Wrong answers are run too
- All 34 listed wrong answers differ from their key, and for each one a script ran a variant of the program (the code the slip pictures, e.g. 7.0 instead of 7) and checked that it really gives that wrong answer. For the two write items, the wrong answers are functions with the slip, run with the same calls.
- Numbers in the working lines
- A script fails if a working line or a wrong-answer note contains a number that isn’t in the item’s code, its key, a value a probe line printed, or the compiler’s or runtime’s own message (0 is always allowed, and so is a number in the wrong answer or its variant code).
- Quotes
- Every card quote and every M0 Answer is a word-for-word quote from 7 saved chapters of The Swift Programming Language (raw Markdown from github.com/swiftlang/swift-book, main branch, read 2026-10-13; copyright Apple Inc. and the Swift project authors; licence Apache License 2.0 with Runtime Library Exception, which each saved chapter’s footer states). A script checks each of the 42 quotes on its saved copy (whitespace collapsed; the source marks some words with *stars* or backticks, and a quote may be written with or without them). It does not re-fetch the live pages. M0 Answers are exactly those quotes (some are the part of a sentence that answers the question), and the tutor grades the facts in them, not the wording. Card lines marked “Run:” show output the script got by running the code. The short bold labels, the plain-word glosses in parentheses on the cards, the working lines and the wrong-answer notes are the course’s own words.
- Honest limits
- One Swift version, so compiler and runtime message wording can differ on yours (the tutor grades Compile error and Runtime error without the message). The book is its current main branch and the keys come from Swift 6.0.3; the course doesn’t compare them line by line. The course doesn’t run your code while you learn: the tutor judges what you type against the keys and working lines, and if you have Swift you can run any item yourself. The two write items are graded by reading your function against the calls shown, not by running it.
- Not in it yet
- The closed-range and argument-label words as M0 questions (they are on the M2 and M3 cards), Set, tuples, enum, struct, closures, try / catch, Foundation, more write-the-function items.