R/isRational.R
isRational.RdIs an object from class rational
Test if an object is of class "rationalS3", "rationalS4", or "rationalR6"
is.rationalS3(e1, inherit = FALSE) is.rationalR6(e1, inherit = FALSE) is.rationalS4(e1, inherit = FALSE) is.rational(e1, inherit = FALSE)
| e1 | object to be tested |
|---|---|
| inherit | should inheritence be checked? default= |
The inherit parameter is included for speed. There is a
performance boost from not checking for inheritence in the class structure.
When inherit==FALSE, the the first class returned from class() is
checked to be equal to "rationalXX". When inherit==TRUE, then the
methods::is() function is used.
stopifnot(is.rationalS3(rational(1L, 2L, "S3"))) stopifnot(!is.rationalS3(7.1)) stopifnot(is.rationalR6(rational(1L, 2L, "R6"))) stopifnot(!is.rationalR6("no")) stopifnot(is.rationalS4(rational(1L, 2L, "S4"))) stopifnot(!is.rationalS4(TRUE)) stopifnot(is.rational(rational(1L, 2L, "S3"))) stopifnot(!is.rational(7.1)) stopifnot(is.rational(rational(1L, 2L, "R6"))) stopifnot(is.rational(rational(1L, 2L, "S4")))