# The typical use of this function is within methods
# Let's create a 'my_class' object and a summary method
my_obj = list()
class(my_obj) = "my_class"
# In the summary method, we add validate_dots
# to inform the user of invalid arguments
summary.my_class = function(object, arg_one, arg_two, ...){
validate_dots()
# CODE of summary.my_class
invisible(NULL)
}
# Now let's test it, we add invalid arguments
summary(my_obj, wrong = 3)
summary(my_obj, wrong = 3, info = 5)
# Now let's :
# i) inform the user that argument arg_one is the main argument
# ii) consider 'info' as a valid argument (but not shown to the user)
# iii) show a message instead of a warning
summary.my_class = function(object, arg_one, arg_two, ...){
validate_dots(valid_args = "info", suggest_args = "arg_one", message = TRUE)
# CODE of summary.my_class
invisible(NULL)
}
# Let's retest it
summary(my_obj, wrong = 3) # not OK => suggestions
summary(my_obj, info = 5) # OK
Run the code above in your browser using DataLab