R/operators.R

Defines functions `%||%`

# copied from https://github.com/tidyverse/rlang/blob/main/R/operators.R

#' Default value for `NULL`
#'
#' This infix function makes it easy to replace `NULL`s with a default
#' value. It's inspired by the way that Ruby's or operation (`||`)
#' works.
#'
#' @param x,y If `x` is NULL, will return `y`; otherwise returns `x`.
#' @name op-null-default
#' @noRd 
`%||%` <- function(x, y) {
  if (is.null(x)) y else x
}

Try the ggview package in your browser

Any scripts or data that you put into this service are public.

ggview documentation built on Oct. 2, 2024, 5:06 p.m.