为什么 'if let' 似乎不像 Swift 3 in Xcode 8.3 beta 中那样拆箱值?
Why 'if let' does not seem to unbox a value as before in Swift 3 in Xcode 8.3 beta?
与以前不同,我惊讶地发现 'title' 现在是一个可选值(编译器现在生成减弱:字符串插值生成可选值的调试描述;您是要明确说明吗? ).
为什么 'if let title =' 表达式不再拆箱了?
我应该怎么做才能在 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!)")
}
}
}
好的,然后这样做可以解决问题:
如果让 item = item 作为? [String: String?], let title = item["label"] ??零 {
/* ... */
}
与以前不同,我惊讶地发现 'title' 现在是一个可选值(编译器现在生成减弱:字符串插值生成可选值的调试描述;您是要明确说明吗? ).
为什么 'if let title =' 表达式不再拆箱了? 我应该怎么做才能在 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!)")
}
}
}
好的,然后这样做可以解决问题:
如果让 item = item 作为? [String: String?], let title = item["label"] ??零 { /* ... */ }