Skip to contents

Check function arguments

Usage

check_args(...)

Arguments

...

Arg definitions.

Value

The caller environment.

Examples

{
  f <- function(a, b) {
    check_args(a = is.integer, b = is.integer)
    a + b
  }

  # Succeeds
  f(10L, 20L)

  # Fails
  try(f(10L, 4.6))
}
#> Error in base_model(fields)(.x = func_env) : Type check(s) failed
#> ---
#> Type check failed for 'b'
#> value:  num 4.6
#> type: double
#> class: numeric
#> length: 1
#> expected: .Primitive("is.integer")