R/util.R

Defines functions if_null_else `%&&%` `%||%`

#' @export
#' @importFrom magrittr %>%
magrittr::`%>%`

#' @export
#' @importFrom magrittr %<>%
magrittr::`%<>%`

#' @export
`%||%` <- function(x, y){
  if(is.null(x)) y else x
}

#' @export
`%&&%` <- function(x, y) {
  if (is.null(x)) NULL else y
}

#' @export
if_null_else <- function(cond, true, false){
  if(is.null(cond)) true else false
}
thackl/thacklr documentation built on Oct. 16, 2023, 9:15 p.m.