design icon indicating copy to clipboard operation
design copied to clipboard

Argument and function name the same

Open hadley opened this issue 2 years ago • 0 comments

library(rlang)

f <- function(mean = mean(10)) {
  mean
}
f()
#> Error in f(): promise already under evaluation: recursive default argument reference or earlier problems?


f <- function(mean = NULL) {
  mean %||% mean(10)
}
f()
#> [1] 10

Created on 2023-10-05 with reprex v2.0.2

Maybe in one of the defaults chapters?

hadley avatar Oct 05 '23 18:10 hadley