類型檢查,我不能這樣做,我認爲應該工作以下類型檢查:斯威夫特
var str:String?
//Compiler error: Downcast from 'String?' to 'String' only unwraps optional; did you mean to use '!'?
if str is String {
}
//Compiler error: is test is always true
if str! is String {
println("str is optional string")
}
我想說明使用is型檢查。 – Boon 2014-09-01 20:21:25