var dict = [Int:Any]() dict[1] = 15
let x = dict[1] as? String print(x)
let zz = dict[1] as! String
dict[2] = "Yo"
let z = dict[2] as! String? print(z) let z2 = dict[2] as! String print(z2)
let m = dict[3] as! String? print(m)
|
警告 Treating a forced downcast to ‘NSNumber’ as optional will never produce ‘nil’
提示 Fix-it use ‘as?’ to perform a conditional downcast to ‘NSNumber’