Learn R Programming

rlang (version 1.1.0)

op-null-default: Default value for NULL

Description

This infix function makes it easy to replace NULLs with a default value. It's inspired by the way that Ruby's or operation (||) works.

Usage

x %||% y

Arguments

x, y

If x is NULL, will return y; otherwise returns x.

Examples

Run this code
1 %||% 2
NULL %||% 2

Run the code above in your browser using DataLab