Skip to contents

%||% If length-0 alternative operator

Usage

a %||% b

Arguments

a

ANY. Element to select only if it is not length 0

b

ANY. Element to select if a is length 0

Value

a, unless it is length 0, in which case b (even in the case b is also length 0)

Examples

6 %||% 10
#> [1] 6

character() %||% "hi"
#> [1] "hi"

NULL %||% "hi"
#> [1] "hi"