-
Notifications
You must be signed in to change notification settings - Fork 118
Open
Description
Wondering if it's worth noting the update for R 4.4.0 here:
Advanced-R-Solutions/13_S3.Rmd
Line 421 in cfdb2b5
| But when we call `g(x)` we get `c(1, 10)`: |
UseMethod creates a new function call with arguments matched as they came in to the generic. [Previously local variables defined before the call to UseMethod were retained; as of R 4.4.0 this is no longer the case.]
Reprex
sessionInfo()
#> R version 4.5.0 (2025-04-11 ucrt)
#> ...
g <- function(x){
x <- 10
y <- 10
UseMethod('g')
}
g.default <- function(x) c(x = x, y = y)
x <- 1
y <- 1
g(x)
#> x y
#> 1 1
g.default(x)
#> x y
#> 1 1
rm(y)
g(x)
#> Error in g.default(x) : object 'y' not foundMetadata
Metadata
Assignees
Labels
No labels