The R Project SVN R

Rev

Rev 58494 | Rev 66586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54325 jmc 1
## reset inherited methods of group members
2
## (contributed by Martin Morgan, 2011-2-9)
3
setClass("A", representation("numeric"))
4
a <- new("A")
5
 
6
setMethod("Logic", c("A", "A"), function(e1, e2) FALSE)
7
res0 <- a & a                           # inherit &,A,A-method
8
setMethod("Logic", c("A", "A"), function(e1, e2) TRUE)
9
stopifnot(a & a)
10
 
11
removeMethod("Logic", c("A", "A"))
12
stopifnot(logical() == a & a)
13
 
14
removeClass("A")
58493 maechler 15
 
16
### Find inherited group methods:
17
stopifnot(require(Matrix))
58511 maechler 18
sm <- selectMethod("-", c("dgCMatrix", "numeric"))# direct match with "Arith"
19
s2 <- selectMethod("-", c("dtCMatrix", "numeric"))# ambiguity match with "Arith"
20
stopifnot(sm@generic == "Arith",
21
          s2@generic == "Arith")
22
## was not ok in R 2.14.x
58493 maechler 23