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

NULL %||% "default"
#> [1] "default"
"value" %||% "default"
#> [1] "value"
list()$missing %||% 0
#> [1] 0