- iOS 12 Programming for Beginners
- Craig Clayton
- 66字
- 2021-07-02 15:05:02
Accessing an item in a dictionary
When trying to access an item inside a dictionary, you will always receive an optional value. The reason for this is that you could potentially receive nil if the value does not exist. So, you should always use an if...let statement to safeguard your code:
if let numChickenPrice = dictPizzas["chicken"] { print(numChickenPrice) }
Your code should now look like this:

推薦閱讀
- 網(wǎng)絡教育學習指導
- 從區(qū)塊鏈到Web3:構建未來互聯(lián)網(wǎng)生態(tài)
- Django 2 by Example
- OpenLayers Cookbook
- 網(wǎng)絡創(chuàng)新指數(shù)研究
- Oracle SOA Suite 11g Performance Tuning Cookbook
- 區(qū)塊鏈輕松上手:原理、源碼、搭建與應用
- 數(shù)字調制解調技術的MATLAB與FPGA實現(xiàn):Altera/Verilog版(第2版)
- IPv6網(wǎng)絡切片:使能千行百業(yè)新體驗
- 4G小基站系統(tǒng)原理、組網(wǎng)及應用
- Learning Storm
- 6G無線網(wǎng)絡空口關鍵技術
- 語音信號處理及Blackfin DSP實現(xiàn)
- 大型企業(yè)微服務架構實踐與運營
- Microservices Development Cookbook