# Direct type checking
check_type(5L, Integer) # Returns TRUE
try(check_type("hello", Integer)) # Throws error
# With context for better error messages
try(check_type(5L, String, context = "user_name"))
# With union types
check_type(5L, Integer | String) # Returns TRUE
try(check_type(5.5, Integer | String)) # Throws error
Run the code above in your browser using DataLab