get()
Returns the success value as a throwing expression.
Declaration
consuming func get() throws(Failure) -> SuccessReturn Value
The success value, if the instance represents a success.
Discussion
Use this method to retrieve the value of this result if it represents a success, or to catch the value if it represents a failure.
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."