isRational: Is an object from class rational

isRationalR Documentation

Is an object from class rational

Description

Test if an object is of class "rationalS3", "rationalS4", or "rationalR6"

Usage

is.rationalS3(e1, inherit = FALSE)

is.rationalR6(e1, inherit = FALSE)

is.rationalS4(e1, inherit = FALSE)

is.rational(e1, inherit = FALSE)

Arguments

e1

object to be tested

inherit

should inheritence be checked? default=FALSE

Note

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.

Examples

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")))

bertcarnell/rational documentation built on Aug. 1, 2024, 8:14 p.m.