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 provided function fn shall be run instead.

Usage

unwrap_or_else(x, fn, ...)

Arguments

x

A Result or Option object.

fn

A single argument function that accepts a Failure or a Nothing.

...

Additional optional arguments that may be used by specific methods.

Examples

Success(10) |> unwrap_or_else(\(errval) { message("Oh no no I failed") })
#> [1] 10
Failure("Oh no I failed!") |> unwrap_or_else(\(errval) { message(errval) })
#> Oh no I failed!