美文网首页
swift2.1 新特性

swift2.1 新特性

作者: Jniying | 来源:发表于2020-04-28 15:13 被阅读0次

在 swift2.1 之前可以通过 ?? 来解包变量

var  username  = nil
print("Hello, \(username ?? "swift")")

在 swift2.1 之后可以通过 ! 来强解包变量

print("Hello, \(user["name"]!)")
PS参考链接

参考Swift版本差异

相关文章

网友评论

      本文标题:swift2.1 新特性

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