and_then: Evaluate a maybe returning function on a maybe value

View source: R/maybe.R

and_thenR Documentation

Evaluate a maybe returning function on a maybe value

Description

Evaluate a maybe returning function on a maybe value

Usage

and_then(.m, .f, ...)

bind(.m, .f, ...)

Arguments

.m

A maybe value

.f

A maybe returning function to apply to the maybe value

...

Named arguments for the function .f

Value

A maybe value

Examples

safe_sqrt <- maybe(sqrt, ensure = not_infinite)

just(9) %>% and_then(safe_sqrt)
just(-1) %>% and_then(safe_sqrt)
nothing() %>% and_then(safe_sqrt)

maybe documentation built on Aug. 7, 2023, 5:11 p.m.