【Swift 60秒】97 - Optionals: Summary_豪冷啊
You've made it to the end of the tenth part of this series, so let's summarize:...
0x00 Lesson
You’ve made it to the end of the tenth part of this series, so let’s summarize:Optionals
let us represent the absence of a value in a clear and unambiguous way.
Swift won’t let us use optionals without unwrapping them, either using if let
or using guard let
.
You can force unwrap optionals with an exclamation mark, but if you try to force unwrap nil our code will crash
.
You can use nil coalescing
to unwrap an optional and provide a default value if there was nothing inside.
You can use try?
to convert a throwing function into an optional return value, or try!
to crash if an error is thrown.
If you need your initializer to fail when it’s given bad input, use init?()
to make a failable initializer.
You can use typecasting
to convert one type of object to another.
0x01 我的小作品
欢迎体验我的作品之一:小笔记-XNote
笔记一步到位!
App Store
搜索即可~
皇冠新体育APP相关的文章
- Redis之redis-cluster集群_代码搬运工阿新
- impala-3.2.0-cdh6.3.0 本地yum源安装_yxluojiecpp
- 头歌MySQL数据库实训答案 有目录_普通网友
- 皇冠新体育APP:MongoDB 常用基本命令_华仔仔coding_mongo 常用命令
- 皇冠新体育APP:瑞吉外卖项目记录_十岁卖切糕、
- 皇冠新体育APP:关系型数据库与非关系型数据库的区别汇总_Eric_Zhang_es是关系型还是非关系型
- 皇冠新体育APP:MySQL-索引及其原理_我叫意志李
- NoSql 数据库 ?? Redis 数据库学习_梦の澜
- 皇冠新体育APP:2022MySQL 8.0.30 安装及配置(详细教程)_She1ry
- 皇冠新体育APP:【Docker】docker+Nginx部署前端项目_程序媛小y
- HBase分页_李某乐_hbase分页设计
- [Spring boot] Spring boot 实现发送邮件功能_天海奈奈
- Phoenix组件安装及使用DBeaver工具进行远程连接_程序猿丶HLK
- 皇冠新体育APP:MySQL基础总结合集_神偷怪盗基德
- mongodb 子集操作汇总(较详细,附带springBoot中的操作)_Aven_w_mongodb 查询子集
- 皇冠新体育APP:redis常见面试题_小雨滴Java