type: Declare type of a function

Description Usage Arguments Examples

Description

A wrapper for 'declare_ls'; just to provide another interface.

Usage

1
type(f, ...)

Arguments

f

A function; the function to which type-annotations are added.

...

The type / classes for each argument.

Examples

1
2
3
4
5
6
7
8
## Not run: 
# Example 1
add_one <- function(x) { x + 1 }
add_one <- declare::type(add_one, x = "numeric")
add_one(10)          # Runs fine
add_one(nrow(1:10))  # Expect type error since nrow of a vector returns NULL.

## End(Not run)

kcf-jackson/declare documentation built on May 29, 2019, 8:34 a.m.