Skip to content

Commit

Permalink
add %||% operator definition
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Dec 6, 2024
1 parent d44eace commit 1f4334d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions R/utils_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ trim_url <- function(url) {
trim_trailing_slash <- function(url) {
sub(pattern = "/$", replacement = "", x = url, perl = TRUE)
}

`%||%` <- function(x, y) {
if (is_null(x)) y else x
}

# Reexport from base on newer versions of R
if (exists("%||%", envir = .BaseNamespaceEnv)) {
`%||%` <- get("%||%", envir = .BaseNamespaceEnv)
}

0 comments on commit 1f4334d

Please sign in to comment.