【发布时间】:2014-06-18 18:04:53
【问题描述】:
在下面的代码中,为什么 expectingThisToBeOptional 是 String 类型而不是 String 类型!当 getOptional() 返回一个字符串时!
func getOptional() -> String!
{
var s:String! = "Hello"
return s
}
if let expectingThisToBeOptional = self.getOptional()
{
// attempting to use expectingThisToBeOptional! gives error saying type is String not String!
}
else
{
// why does execution come here when run?
}
【问题讨论】:
标签: swift