XCode 16.4 日本語化計画
成功の値を throw する式として返します。
consuming func get() throws(Failure) -> Success
Failure が Error に準拠している場合に使用できます。
このインスタンスが success (成功) を表す場合の成功の値。
このメソッドを使用して、この結果が成功を表す場合はその値を取得し、失敗を表す場合はその値を catch します。
let integerResult: Result<Int, Error> = .success(5)
do {
let value = try integerResult.get()
print("The value is \(value).")
} catch {
print("Error retrieving the value: \(error)")
}
// Prints "The value is 5."