Intermediate Vocabulary #swift #ios #optionals #concurrency

Swift Vocabulary

5 exercises — optionals (guard let / if let), value vs reference types, retain cycles, opaque return types (some), and Swift Concurrency (actor, @MainActor).

0 / 5 completed
Swift vocabulary quick reference
  • Optionals: guard let = early exit + scoped binding; if let = conditional block; ?. = optional chaining; ?? = nil coalescing
  • struct = value type (copy); class = reference type (shared); mutating = method that modifies a struct
  • retain cycle — circular strong references; fix with [weak self] in closures
  • some Protocol = opaque return type (static dispatch); any Protocol = existential (dynamic dispatch)
  • actor — reference type with automatic state isolation; @MainActor = main thread enforcement
1 / 5
A Swift code review says: "Always use guard let at the top of a function instead of nested if let — it keeps the happy path unindented." What is the difference between guard let and if let for unwrapping optionals?