Skip to contents

[Stable]

If the provided object is a Failure (in the case of a Result input) or Nothing (in the case of an Option input), then the function will return the provided default value instead.

Usage

unwrap_or_default(x, default, ...)

Arguments

x

The object to unwrap.

default

The default value to return in the event that x is a Failure.

...

Additional optional arguments that may be used by specific methods.

Value

The value wrapped by a Success or default in the case of a Failure.

See also

Examples

Success(10) |> unwrap_or_default(200)
#> [1] 10
Failure("OMG I failed") |> unwrap_or_default(200)
#> [1] 200
Some(50) |> unwrap_or_default(200)
#> [1] 50
Nothing() |> unwrap_or_default(200)
#> [1] 200