Ok {matchr}R Documentation

Create an 'Ok' Result

Description

Create an Enum variant of Result used to denote that function did not contain an error. This allows the creation of safer functions.

Usage

Ok(x)

Arguments

x

Object to be wrapped in the Enum variant.

Value

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

Examples

grepl_safe <- function(pattern, x)
{
  if (!is.character(pattern)){ return(Err("'pattern' in 'grepl_safe' was not a character value.")) }
  if (!is.character(x)){ return(Err("'x' in 'grepl_safe' was not a character value.")) }
  Ok(grepl(pattern, x))
}

#grepl_safe(123, 1:5)


[Package matchr version 0.1.0 Index]