Why doesn't the “if yes” seem to override the values ​​as before in Swift 3 in the beta version of Xcode 8.3?

Unlike the previous ones, I was surprised to see that "title" is now optional (the compiler now generates waning: String interpolation creates a debug description for the optional value, would you like to make it explicit?).

How did the expression if if title = 'does no unbox it? What to do with unpacking in if?

// Go thru all publication where the tag has been found for item in items { if let item = item as? [String: String?], let title = item["label"] { i += 1 if let rawSummary = item["libSousTheme"] { print("\(i)) Tag [\(foundTag)] z[\(foundZTag)] in « \(title) »") } else { print("\(i)) Tag [\(foundTag)] z[\(foundZTag)] in « \(title) » (no summary!)") } } } 
0
let if-statement swift swift3
Mar 01 '17 at 22:42
source share
1 answer

Ok, then doing this, for example, solves the problem:

if item item = item as? [String: String?], Let title = item ["label"] ?? nil {/ * ... * /}

+1
Mar 01 '17 at 23:12
source share



All Articles