exit_call | R Documentation |
on.exit()
in a parent functionThe function on.exit()
is often used to perform tasks when the
current function exits. This exit_call()
function allows calling a
function when a parent function exits (thinking of it as inserting an
on.exit()
call into the parent function).
exit_call(fun, n = 2, ...)
fun |
A function to be called when the parent function exits. |
n |
The parent frame number. For |
... |
Other arguments to be passed to |
This function was inspired by Kevin Ushey: https://yihui.org/en/2017/12/on-exit-parent/
f = function(x) {
print(x)
xfun::exit_call(function() print("The parent function is exiting!"))
}
g = function(y) {
f(y)
print("f() has been called!")
}
g("An argument of g()!")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.