hasMethod
Search for a Method for a Generic Function

Description

Checks if a generic function has a method with a given signature, possibly via class extensions or group generics.

Usage

hasMethod(f, signature = character(),
          where = .genEnv(f, topenv(parent.frame())))

Arguments

f a character string. The name of the generic function.
signature a string vector. The signature of the method to search for. If signature is not supplied, searches for a default method.
where the package environment to search. Supply either an environment defining a package or a number representing its position in the search path. If where is missing, all attached packages are searched.
Value
returns a logical value. TRUE if the generic function has a method (possibly via class extensions or group generics) for signature sig; otherwise returns FALSE.
See Also
existsMethod, getMethod, selectMethod, findMethod
Examples
setGeneric("setG", function(x)standardGeneric("setG"))
setMethod("setG", "numeric", function(x) x^2)
hasMethod("setG")
# FALSE -- has no default method
hasMethod("setG","numeric")
# TRUE -- has method with this signature
hasMethod("setG","integer")
# TRUE -- has inherited method for this signature
Package methods version 6.1.1-7
Package Index