原文链接🔗
喵神:行走在Swift的世界中 https://onevcat.com/2014/06/walk-in-swift/
知乎:什么是语法糖 https://www.zhihu.com/question/20651624
csdn:语法糖 简单却不那么简单 http://www.cocoachina.com/ios/20160831/17441.html
视频链接🔗https://www.youtube.com/watch?v=i_UXRcydibQ
一个关于💣的故事:
Just think of optional just like a box right so someone give you about a KN gift box right so think of optional as about and then when you inside this box right ,inside this box then we something to read some values and integers and picturing anything you want to use.So in order to use that thing inside you have to unwrap the optional.ou have to engrave the optional and you r that thing in fact that you can check out and use it ,you can call method so that you can access the properties of that thing but inside that is nil meaning that there’s nothing inside this box when you open it and you want to use it you’ll be like next .there’s like a bomb beside.this and Swift does it allow you to do that so that is the case if the optional is nil and you want to use it you unwrap it and then you have a crush so there are two situations right okay optional is like a box. inside the optional of the recent bag if you want to use the value you have to unwrap it. but you unwrap it and the optional is nil then you have to crash .so how can we prevent that.that is what we talked about with optional binding .it is a way for us to bind the values of the optional if the value exists. A safe way to unwrap an optional
//代码
屏幕快照 2018-06-26 下午3.29.08.png
Optional定义屏幕快照 2018-06-26 下午4.15.51.png 拆盒子屏幕快照 2018-06-26 下午3.45.13.png
Optional Binding屏幕快照 2018-06-26 下午4.16.50.png lxjnihaomeia.jpeg
网友评论