try({
# Assert that a variable is a list
x <- list(1, 2, 3)
assert_list(x) # does nothing
# Assert that a variable is not a list
x <- "not a list"
assert_list(x) # stops execution and prints an error message
})
Run the code above in your browser using DataLab