Skip to contents

Resolves the value of a fallback chain defined with fallback().

Usage

resolve_fallback(fallback)

Arguments

fallback

A fallback chain defined with fallback().

Examples


f <- function(x = fallback(TRUE)) {
  resolve_fallback(x)$value
}

f() # with no config files in place, this resolves to the terminal fallback.
#> resolving argument x (terminal fallback)
#> 
#> [1] TRUE
dir <- tempdir()
dir1 <- fs::path(dir, "dir1")
fs::dir_create(dir1)
yaml::write_yaml(list(frog = 100), fs::path(dir1, "config.yaml"))


g <- function(frog = fallback(letters, hierarchy = dir1)) {
  resolve_fallback(frog)$value
}

# this should resolve to the fallback declared in dir1
g()
#> resolving argument frog (terminal fallback)
#> 
#>  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "u" "v" "w" "x" "y" "z"