type | R Documentation |
This function interprets the syntactic typing sugar and produces a standard R
function, stripping type annotations from the function header and embedding
them as a call to type_check
as the first expression in the function body.
type(fn, ...)
fn |
A function to post-process |
fn
with type annotations stripped from the function header and
passed instead to a call to type_check
.
fn <- type(function(a = 1 :numeric) { print(a + 2) }) fn #> function (a = 1) { #> type_constrain(type_check(character(0), a = numeric)) #> print(a + 2) #> } fn(3) #> [1] 5 fn("test") #> Error in throw_type_check_error(signature, name) : #> Type of parameter 'a' does not match signature `numeric`
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.