Some {matchr}R Documentation

Create an 'Some' Option

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

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

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


[Package matchr version 0.1.0 Index]