Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
new_player <- function(name, points) { p <- list(name = name, points = points) class(p) <- "player" p } describe <- function(obj) { UseMethod("describe") } describe.player <- function(obj) { paste(obj$name, "has", obj$points, "points") } describe.default <- function(obj) { "Unknown object" } john <- new_player("John", 45) describe(john) describe(10)
[1] "John has 45 points"
[1] "Unknown object"