zlength-zero-default: Default value for an object length being 0

Description Usage Arguments Examples

Description

The purrr package has %||% which is super-useful when wanting to infix a default value for an object being NULL. This function does the same for length(x) == 0.

Usage

1
x %|0|% y

Arguments

x, y

if x has length 0, will return y; otherwise it returns x

Examples

1
2
3
1 %|0|% 2
NULL %|0|% 2
character(0) %|0|% 2

hrbrmstr/sanipy documentation built on May 20, 2019, 11:58 a.m.