Implicitly Unwrapped Optionals and When to Avoid Them
When IUOs are appropriate and the risks of forced unwrapping.
Welcome
Implicitly Unwrapped Optionals (IUOs) are declared with `!` instead of `?`. They act like optionals but unwrap automatically — which is convenient but dangerous.
Declaring an IUO
```swift
var name: String! = "Alice"
print(name) // "Alice" — auto-unwrapped
print(name.count) // 5
```
No explicit unwrapping syntax needed. But if `name` is nil when accessed, the app crashes.
All lessons in this course
- if let and guard let Binding
- Nil Coalescing and Ternary with Optionals
- Optional Chaining ?. Operator
- Implicitly Unwrapped Optionals and When to Avoid Them