下面是变量名 yourname 和 yourname2 的可选字符串的代码。
实际上,它们之间有什么区别以及在 yourname2 的情况下如何强制展开
var yourname:String?
yourname = "Paula"
if yourname != nil {
println("Your name is \(yourname)")
}
var yourname2:String!
yourname2 = "John"
if yourname2 != nil {
println("Your name is \(yourname2!)")
}