swift 可选绑定

来源:互联网 发布:网络安全检查自查报告 编辑:程序博客网 时间:2024/06/15 15:33
        var optionalInteger: Int?         // 方式一//        if let optionalInteger = optionalInteger {//            print(optionalInteger)//            return//        } else{//            print("no value");//        }        // 方式二 可选绑定        optionalInteger = 42        guard let optional = optionalInteger else {            print("No Value")            return        }        print(optional)
原创粉丝点击