Learn R Programming

fb4package (version 2.0.0)

op-null-default: Null-coalescing operator

Description

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

Usage

x %||% y

Value

x if not NULL, otherwise y

Arguments

x

Value to test

y

Fallback value if x is NULL

Examples

Run this code
NULL %||% "default"
"value" %||% "default"
list()$missing %||% 0

Run the code above in your browser using DataLab