Some: Create an 'Some' Option

Description Usage Arguments Value Examples

View source: R/result_option.R

Description

Create an Enum variant of Option used to denote that function returned a value. This allows the creation of safer functions that extract values from other objects, without using try or tryCatch.

Usage

1
Some(x)

Arguments

x

Object to be wrapped in the Enum variant.

Value

a list with a single value x and classes "Option} and \code{"Enum

Examples

1
2
3
4
subset_safe <- function(x, index) {
  if (index > length(x)){ return(None) }
  Some(x[index])
}

matchr documentation built on Sept. 9, 2021, 5:07 p.m.

Related to Some in matchr...