null_switch {rando}R Documentation

Evaluate Expressions until not NULL

Description

Evaluates expressions until one that is not NULL is encountered and returns that. Expressions after the first non-NULL result are not evaluated. If all expressions are NULL, it will return NULL

Usage

null_switch(...)

Arguments

...

expressions to try to evaluate

Value

The result of evaluating one of the expressions. Will only be NULL if they all evaluated to NULL

Examples

f <- function() {
  cat("Evaluating f\n")
  NULL
}
g <- function() {
  cat("Evaluating g\n")
  2
}

null_switch(NULL, f(), g())
null_switch(NULL, g(), f())
null_switch(f(), f(), f())

[Package rando version 0.2.0 Index]