return_if_null {portalr} | R Documentation |
If a Value is NULL, Trigger the Parent Function's Return
Description
If the focal input is NULL
, return value
from the parent function. Should only be used within a function.
Usage
return_if_null(x, value = NULL)
Arguments
x |
Focal input. |
value |
If |
Value
If x
is not NULL
, NULL
is returned. If x
is NULL
, the result of return
with value
as its input evaluated within the parent function's environment is returned.
Examples
ff <- function(x = 1, null_return = "hello"){
return_if_null(x, null_return)
x
}
ff()
ff(NULL)
[Package portalr version 0.4.1 Index]