语法 - If not let - in Swift
变更记录
序号 | 录入时间 | 录入人 | 备注 |
---|---|---|---|
1 | 2015-04-13 | Alfred Jiang | - |
2 | 2015-12-23 | Alfred Jiang | - |
方案名称
语法 - If not let - in Swift
关键字
语法 \ optional \ ? \ ! \ if let
需求场景
- 判断 optional 字段是否有效\无效时
参考链接
详细内容
正常的 if let 用法
1 | if let type = json.type { |
if not let 实现
1 | func ifNotLet<T>(optional: T?, closure: @autoclosure () -> ()) -> T { |
效果图
(无)
备注
(无)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 宁静至远,博雅多通!