utilities: General utility functions

compactR Documentation

General utility functions

Description

General utility functions

Usage

compact(.x)

a %||% b

check_dots_named(dots, call = rlang::caller_env())

Arguments

.x

a list

a

an R object

b

an R object

dots

a list collected from dots via rlang::list2(...)

call

default rlang::caller_env(). The caller environment passed to cli::cli_abort()

Details

  • compact() removes any NULL list elements

  • ⁠%||%⁠ is a special pipe operator that returns b if a is NULL

Value

  • compact() a list

  • ⁠%||%⁠ the first non-null item or NULL if both are NULL

Examples


# remove null elements
compact(list(a = NULL, b = 1))

# if NULL return rhs
NULL %||% 123

# if not NULL return lhs
123 %||% NULL


arcgisutils documentation built on April 12, 2025, 1:16 a.m.