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
null_switch(...)
... | expressions to try to evaluate |
---|
The result of evaluating one of the expressions. Will only be
NULL
if they all evaluated to NULL
f <- function() { cat("Evaluating f\n") NULL } g <- function() { cat("Evaluating g\n") 2 } null_switch(NULL, f(), g())#> Evaluating f #> Evaluating g#> [1] 2null_switch(NULL, g(), f())#> Evaluating g#> [1] 2null_switch(f(), f(), f())#> Evaluating f #> Evaluating f #> Evaluating f#> NULL