- Swift 4 Programming Cookbook
- Keith Moon
- 223字
- 2021-07-08 10:21:22
Optionals, unwrap, and force unwrap
In the real world, we don't always know the answer to a problem, and problems can occur if we blindly assume that someone does. The same is true in programming languages, especially when dealing with external systems that we may not control. In many languages, including Objective-C (until recently), there was no way to indicate that something being declared may not exist at the time you attempt to access it. This would lead to either fragile code that could have broken if a nil unexpectedly found its way in or tests being run all over the code to ensure that a value did exist where it was needed, which added complexity and increased the boilerplate code that had to be written.
With a focus on Swift being type-safe and making it easier to write safe code, this ambiguity had to be addressed, and the Swift language does this with the use of optionals.
- Mastering JavaScript Functional Programming
- DBA攻堅指南:左手Oracle,右手MySQL
- 機器學習系統:設計和實現
- Python數據分析入門與實戰
- Java開發入行真功夫
- Windows Presentation Foundation Development Cookbook
- Android 應用案例開發大全(第3版)
- 網絡爬蟲原理與實踐:基于C#語言
- ElasticSearch Cookbook(Second Edition)
- Instant PHP Web Scraping
- 微課學人工智能Python編程
- Windows Phone 8 Game Development
- C陷阱與缺陷
- RocketMQ實戰與原理解析
- Java 9 with JShell