AceMobileInterview

iOS track

General topic questions

Optionals and Nil Coalescing

EasyCommon

Free section · general topics & algorithms

How do optionals work, and when would you use ?, !, if let, guard let, and ??

Reveal model answer
Optionals wrap absence of a value. Prefer if let/guard let for safe unwraps; ?? for defaults; avoid force unwrap (!) except when truly impossible to be nil. Optional chaining (?.) short-circuits safely.
Result TypeValue vs Reference Types