Pebble Coding

ソフトウェアエンジニアによるIT技術、数学の備忘録

swift5.7(Xcode14)で気になる機能

SE-0345 if let shorthand for shadowing an existing optional variable

swift-evolution/proposals/0345-if-let-shorthand.md at main · apple/swift-evolution · GitHub

同じ変数名でunwrapする際に簡略化して書けるようになりました。
これ助かる。

Xcode13未満

let longVariableName: Int? = 3
guard let longVariableName = longVariableName else {
    ...
}

Xcode14以上

let longVariableName: Int? = 3
guard let longVariableName else {
    ...
}