View source: R/dots-ellipsis.R
check_dots_used | R Documentation |
When ...
arguments are passed to methods, it is assumed there
method will match and use these arguments. If this isn't the case,
this often indicates a programming error. Call check_dots_used()
to fail with an error when unused arguments are detected.
check_dots_used(
env = caller_env(),
call = caller_env(),
error = NULL,
action = deprecated()
)
env |
Environment in which to look for |
call |
The execution environment of a currently
running function, e.g. |
error |
An optional error handler passed to |
action |
In packages, document ...
with this standard tag:
@inheritParams rlang::args_dots_used
check_dots_used()
implicitly calls on.exit()
to check that all
elements of ...
have been used when the function exits. If you
use on.exit()
elsewhere in your function, make sure to use add = TRUE
so that you don't override the handler set up by
check_dots_used()
.
Other dots checking functions:
check_dots_empty()
,
check_dots_unnamed()
f <- function(...) {
check_dots_used()
g(...)
}
g <- function(x, y, ...) {
x + y
}
f(x = 1, y = 2)
try(f(x = 1, y = 2, z = 3))
try(f(x = 1, y = 2, 3, 4, 5))
# Use an `error` handler to handle the error differently.
# For instance to demote the error to a warning:
fn <- function(...) {
check_dots_empty(
error = function(cnd) {
warning(cnd)
}
)
"out"
}
fn()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.