Learn R Programming

S7 (version 0.1.1)

class_missing: Special dispatch types

Description

  • Use class_missing when the user has not supplied an argument

  • Use class_any for a default method that is called only if no other methods are matched

Usage

class_missing

class_any

Arguments

Value

Sentinel objects used for special types of dispatch.

Format

An object of class S7_missing of length 0.

An object of class S7_any of length 0.

Examples

Run this code
foo <- new_generic("foo", "x")
method(foo, class_integer) <- function(x) "integer"
method(foo, class_missing) <- function(x) "missing"
method(foo, class_any) <- function(x) "fallback"

foo(1)
foo()
foo("x")

Run the code above in your browser using DataLab