01 — optionals
Nil lives in the type system; unwrapping is explicit and checked.
var port: String? = "osaka"
if let p = port {
print(p.uppercased()) // only runs when non-nil
}← the guideMulticore & Missions
§ 02 — Eras · 2014
Objective-C’s heir — safe by default, friendly on purpose
Left: era context, features, and the 101 hello. Right: 3 core concepts, 3 deeper 201 lessons, the factorial specimen, and where Swift lives today — each column scrolls on its own.
Objective-C repelled newcomers and memory bugs persisted. Swift made safety the default and modern syntax the attraction.
A decade of source-breaking churn, an ABI saga — and gravity: it lives almost entirely inside Apple’s orbit.
Session one is the smallest program that still counts as speaking Swift: what every tutorial prints first, in the dialect that mattered when the language arrived (2014).
print("Hello, world")101First contact — hello world and 3 ideas that define how Swift reads. 201 — 3 lessons on mechanisms you meet after the factorial specimen: the sharp edges practitioners actually use.
3 fragments, each naming a habit of mind in Swift. Read the note, then the code — together they are the 101 in one sitting.
01 — optionals
Nil lives in the type system; unwrapping is explicit and checked.
var port: String? = "osaka"
if let p = port {
print(p.uppercased()) // only runs when non-nil
}02 — structs & protocols
Value types plus protocols — Swift’s answer to classes-everywhere.
protocol Dockable {
func dock() -> String
}
struct Ship: Dockable {
let name: String
func dock() -> String { "(name) docked" }
}03 — closures
Shorthand arguments ($0) and key paths make function-valued code terse.
let raised = wages.map { $0 + 5 }
let names = ships.map(\.name)The 201 assumes you have read the 101 and the specimen. Each lesson is one mechanism — what it is for, how it looks in code, and the trap or payoff that makes Swift distinctive at scale.
Automatic reference counting frees memory for you — unless two objects hold each other, which weak and unowned references break.
final class Port {
weak var city: City?
}Protocols with associated types constrain what a generic can hold; protocol extensions add default behaviour without inheritance.
protocol Dockable { func dock() }
extension Dockable {
func dockAndLog() { dock(); print("docked") }
}async/await with task groups keeps child tasks scoped to their parent, so cancellation propagates and no task outlives its work.
await withTaskGroup(of: Int.self) { group in
for port in ports { group.addTask { await fetch(port) } }
for await value in group { total += value }
}The optional: null moves into the type system — you cannot forget the nil case, because the compiler will not let you.
var port: String? = "osaka"
if let p = port {
print(p.uppercased())
}runswift fact.swift
iOS, macOS, visionOS — effectively the floor of the App Store — plus server frameworks like Vapor.