-
UseMethod()
has a special way of calling methods which has some weird consequences. Predict what the following code will return, then run it and read the help forUseMethod()
to figure out what's going on. Write down the rules in the simplest form possible.y <- 1 g <- function(x) { y <- 2 UseMethod("g") } g.numeric <- function(x) y
g(10)