代码适用于 Xcode 12.5 但不适用于 Xcode 12.4
Code works on Xcode 12.5 but not Xcode 12.4
此代码在 Xcode 12.5.1 和 13
上编译良好
private func maskOtherLocalAccount(number: String?) -> String {
guard let number = number, number.count > 5 else { return number ?? "-"}
}
但是在 Xcode 12.4 上,它给出了这个编译错误:
Variable declared in 'guard' condition is not usable in its body
虽然修复很容易,但我发现它在 Xcode 12.5.1 而不是 12.4 上工作真的很奇怪。
有人可以指出记录此更改的官方更改日志吗?
SR-8669报道:
If you attempt to use a guard statement to declare a variable that shadows an existing variable, a compiler error prevents you from accessing the existing variable in the body of the guard.
这几乎在整整一年前就已被标记为已解决,与 Xcode 12.5 的发布日期相符。
此代码在 Xcode 12.5.1 和 13
上编译良好private func maskOtherLocalAccount(number: String?) -> String {
guard let number = number, number.count > 5 else { return number ?? "-"}
}
但是在 Xcode 12.4 上,它给出了这个编译错误:
Variable declared in 'guard' condition is not usable in its body
虽然修复很容易,但我发现它在 Xcode 12.5.1 而不是 12.4 上工作真的很奇怪。 有人可以指出记录此更改的官方更改日志吗?
SR-8669报道:
If you attempt to use a guard statement to declare a variable that shadows an existing variable, a compiler error prevents you from accessing the existing variable in the body of the guard.
这几乎在整整一年前就已被标记为已解决,与 Xcode 12.5 的发布日期相符。