Some {matchr} | R Documentation |
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
.
Some(x)
x |
Object to be wrapped in the Enum variant. |
a list with a single value x
and classes "Option} and \code{"Enum
subset_safe <- function(x, index) {
if (index > length(x)){ return(None) }
Some(x[index])
}