Learn R Programming

infix (version 0.1.0)

nil: Default value for NULL

Description

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

Usage

a %||% b

Arguments

a, b

If a is NULL, will return b; otherwise returns a.

Examples

Run this code
# NOT RUN {
1 %||% 2 # returns 1
NULL %||% 2 # returns 2
# }

Run the code above in your browser using DataLab