Examples for 'base::.S3method'


Register S3 Methods

Aliases: .S3method

Keywords:

### ** Examples

## Create a generic function and register a method for objects
## inheriting from class 'cls':
gen <- function(x) UseMethod("gen")
met <- function(x) writeLines("Hello world.")
.S3method("gen", "cls", met)
## Create an object inheriting from class 'cls', and call the
## generic on it:
x <- structure(123, class = "cls")
gen(x)
Error in UseMethod("gen"): no applicable method for 'gen' applied to an object of class "cls"

[Package base version 4.2.3 Index]