Instance Method


Returns the success value as a throwing expression.


func get() throws -> Success

Return Value

The success value, if the instance represents a success.


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 error {
    print("Error retrieving the value: \(error)")
// Prints "The value is 5."