maybe_case {maybe}R Documentation

Unwrap and call a function on a maybe value or return a default

Description

Unwrap and call a function on a maybe value or return a default

Usage

maybe_case(.m, .f, default)

Arguments

.m

A maybe value

.f

A function to apply to the maybe value in the case of 'Just'

default

A default value to return in the case of 'Nothing'

Value

The return value of the 'Just' function or the default value

Examples

just(1:10) %>% maybe_case(mean, 0)
nothing() %>% maybe_case(mean, 0)

[Package maybe version 1.1.0 Index]