Chapter 4. Making optionals second nature
This chapter covers
- Best practices related to optionals
- Handling multiple optionals with guards
- Properly dealing with optional strings versus empty strings
- Juggling various optionals at once
- Falling back to default values using the nil-coalescing operator
- Simplifying optional enums
- Dealing with optional Booleans in multiple ways
- Digging deep into values with optional chaining
- Force unwrapping guidelines
- Taming implicitly unwrapped optionals
This chapter helps you acquire many tools to take you from optional frustration to optional nirvana while applying best practices along the way. Optionals are so pervasive in Swift that we spend some extra pages on them to leave no stone unturned. Even ...
Get Swift in Depth now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.