add_numbers <- function(a, b) {
collection <- checkmate::makeAssertCollection()
checkmate::assert_numeric(x = a, add = collection)
checkmate::assert_numeric(x = b, add = collection)
report_checkmate_assertions(collection)
return(a + b)
}
add_numbers(1, 2)
try(add_numbers(1, "b"))
try(add_numbers("a", "b"))
Run the code above in your browser using DataLab