私はこれをやりたいと思っています:
do {
let result = try getAThing()
} catch {
//error
}
do {
let anotherResult = try getAnotherThing(result) //Error - result out of scope
} catch {
//error
}
しかし、これしかできないようです:
do {
let result = try getAThing()
do {
let anotherResult = try getAnotherThing(result)
} catch {
//error
}
} catch {
//error
}
result
do/catch ブロックをネストすることなく、不変をスコープ内に保持する方法はありますか? guard
if/else ブロックの逆としてステートメントを使用する方法と同様に、エラーを防ぐ方法はありますか?