try({
# Assert that a variable is a function
x <- function(a, b) { a + b }
assert_function(x) # does nothing
# Assert that a variable is not a function
x <- "not a function"
assert_function(x) # stops execution and prints an error message
})
Run the code above in your browser using DataLab