and_then {maybe} | R Documentation |
Evaluate a maybe returning function on a maybe value
and_then(.m, .f, ...)
bind(.m, .f, ...)
.m |
A maybe value |
.f |
A maybe returning function to apply to the maybe value |
... |
Named arguments for the function |
A maybe value
safe_sqrt <- maybe(sqrt, ensure = not_infinite)
just(9) %>% and_then(safe_sqrt)
just(-1) %>% and_then(safe_sqrt)
nothing() %>% and_then(safe_sqrt)