Precondition: Constructor of the class Precondition

Description Usage Arguments Value Examples

View source: R/Precondition.R

Description

Utility functions for checking the type of an argument, based on TypeChecker in the same package. If the argument is not of the expected type, an error will be thrown. Usually, these utility functions are called at the begining of a function body.

Usage

1
Precondition(allowNA = FALSE, allowNull = FALSE)

Arguments

allowNA

Should NA be allowed? The method checkIsNull ignores this parameter.

allowNull

Should NULL be allowed? The method checkIsNA ignores this parameter.

Value

an instance of Precondition

Examples

1
2
3
4
5
precondition <- Precondition()
myFunction <- function(x) {
  precondition$isNumeric(x, 'x should be numeric')
  ...
}

cartowong/oo documentation built on May 21, 2019, 2:21 p.m.