Skip to contents

Returns x if it is non-NULL, otherwise returns y. A lightweight alternative to rlang::%||% that avoids adding a heavy dependency.

Usage

x %||% y

Arguments

x, y

Any R objects.

Value

x if !is.null(x), else y.

Examples

NULL %||% "default"   # "default"
#> [1] "default"
"value" %||% "other"  # "value"
#> [1] "value"