0

我想知道是否有一个命名约定来解开可选值。

var x: Int? = 0

if let x = x {
}
// OR ?
if let _x = x {
}

许多博客文章都使用第一种情况。

但是,如果我参考WWDC 2014 session 402 (Introduction to Swift) Apple 正在使用:

if let legCount = possibleLegCount {
    println("An aardvark has \(legCount) legs")
}

那么这个时候有正式的约定吗?

4

0 回答 0