美文网首页
2018-06-26Optional语法糖 Optional B

2018-06-26Optional语法糖 Optional B

作者: 胖渣大橘子 | 来源:发表于2018-06-26 12:48 被阅读0次

原文链接🔗
喵神:行走在Swift的世界中 https://onevcat.com/2014/06/walk-in-swift/
知乎:什么是语法糖 https://www.zhihu.com/question/20651624
csdn:语法糖 简单却不那么简单 http://www.cocoachina.com/ios/20160831/17441.html

Optional.png

视频链接🔗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
//代码

开盒子.jpeg
屏幕快照 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

相关文章

  • 2018-06-26Optional语法糖 Optional B

    原文链接?喵神:行走在Swift的世界中 https://onevcat.com/2014/06/walk-in-...

  • ES新特性

    optional chaining 本质:语法糖 年份:2020 optional chaining 可选链。主要...

  • swift 可选类型(optional)

    可选类型定义 Swift 标准库中定义后缀 ?为可选类型 Optional 的语法糖,这里语法糖...

  • 多重 Optional

    /* Optional 我们使用类型后面加上?的语法只不过是Optional类型的语法糖,而实际这个类型是一个en...

  • JS 里的数据类型

    // optional chain 语法 console.log(obj?.a?.b?.c?.name) js有7...

  • Swift 中 ! 和 ?的区别

    ! 和 ? 其实分别是Swift语言中对一种可选类型( Optional) 操作的语法糖。 !: 强制拆包,不管有...

  • Dart的一些语法糖(持续更新)

    语法糖 ?. 与 ?? dart 语法糖 ?. dart 语法糖 ??

  • Swift语法糖的使用

    Swift语法糖的使用 语法糖的简介 语法糖Selector例子 语法糖的简介 我个人对语法糖的理解就是让你的代码...

  • Vue 注册组件语法糖

    注册组件语法糖 一、注册局部组件语法糖 二、注册全局的语法糖

  • Swift语法糖的使用

    Swift语法糖的使用 这个是哪里看的忘记了,反正内容不是我写的 语法糖的简介 语法糖Selector例子 语法糖...

网友评论

      本文标题:2018-06-26Optional语法糖 Optional B

      本文链接:https://www.haomeiwen.com/subject/cqlpyftx.html