powered by
General utility functions
compact(.x)a %||% bcheck_dots_named(dots, call = rlang::caller_env())
a %||% b
check_dots_named(dots, call = rlang::caller_env())
compact() a list
compact()
%||% the first non-null item or NULL if both are NULL
%||%
NULL
a list
an R object
a list collected from dots via rlang::list2(...)
rlang::list2(...)
default rlang::caller_env(). The caller environment passed to cli::cli_abort()
rlang::caller_env()
cli::cli_abort()
compact() removes any NULL list elements
%||% is a special pipe operator that returns b if a is NULL
b
a
# remove null elements compact(list(a = NULL, b = 1)) # if NULL return rhs NULL %||% 123 # if not NULL return lhs 123 %||% NULL
Run the code above in your browser using DataLab