Exercise 2: guard let vs. ?? — Possible Solution ====================================================== Version 1 — guard let (early exit): func describe(age: Int?) { guard let age else { print("Age not provided") return } print("Age is \(age)") } describe(age: nil) // Prints: Age not provided describe(age: 34) // Prints: Age is 34 Version 2 — ?? (nil-coalescing, single print call): func describe(age: Int?) { print(age.map { "Age is \($0)" } ?? "Age not provided") } (A simpler, slightly less idiomatic but equally valid alternative for this specific case, avoiding `map`:) func describe(age: Int?) { let ageText = age != nil ? "Age is \(age!)" : "Age not provided" print(ageText) } WHEN EACH STYLE IS THE BETTER REAL CHOICE: guard let genuinely shines when there's real, meaningful WORK to do only in the non-nil case, and an early return cleanly separates the "nothing to do" case from the "do the real work" case - especially once the function has more than one line of real logic after the unwrap. It keeps the main, non-nil-handling code at the function's own top level, unindented, which stays readable as a function grows. ?? is the better real choice for a short, single-expression fallback - producing one value (or one simple action, like a single print call) regardless of which branch is taken, with no meaningfully different work to do in either case beyond substituting a default. Forcing a full guard-let block for a case this simple would genuinely be more verbose than the problem calls for. As a rough real rule of thumb: guard let for "do real work only if present, otherwise bail early"; ?? for "use this value, or fall back to a simple default" in one line. ANSWER: Both approaches correctly handle the nil and non-nil cases. guard let is the better choice when there's real follow-on logic to run only in the non-nil case, since it separates the early-exit case cleanly at the top of the function. ?? is the better choice for a short, single-value fallback with no real extra work in either branch, since a full guard-let block would be unnecessarily verbose for that simpler shape. WHY THIS WORKS AS AN ANSWER ------------------------------ This provides two correct, real Swift implementations and gives a concrete, practical rule for choosing between guard let and ?? based on how much real work follows the unwrap, rather than treating them as interchangeable.