coalesce: Coalesce two R objects

Description Usage Arguments Examples

Description

I first saw this function in a talk by Jenny Bryan at UseR! 2018. I hear it referred to as "coalesce", most likely named after the SQL function. I later found it out it was actually included in rlang, but I tend to keep my own implementation of the function (and its unit tests) rather than introduce a dependency.

Usage

1
x %||% y

Arguments

x

Any R object, possibly NULL

y

Any R object, possibly NULL

Examples

1
2
3
3 %||% NULL
NULL %||% "red panda"
NULL %||% NULL %||% 42

mdneuzerling/neuzr documentation built on Dec. 21, 2021, 4:51 p.m.