Skip to contents

Returns x if it is not NULL, otherwise returns y. Equivalent to rlang::%||% but without requiring that dependency.

Usage

x %||% y

Arguments

x

Value to test

y

Fallback value if x is NULL

Value

x if not NULL, otherwise y

Examples

if (FALSE) { # \dontrun{
NULL %||% "default"   # Returns "default"
"value" %||% "default" # Returns "value"
list()$missing %||% 0  # Returns 0
} # }