Append values to function body
Arguments
- fun
function
.- values
call
. Quoted values (i.e. call) to slot in the function body.- after
integer(1)
. Where to append in thebody
. The default of1L
places directly after the opening curly bracket.
Examples
## Add a deprecation call into function body.
fun <- function() {
print("hello world")
}
body(fun)
#> {
#> print("hello world")
#> }
## values: call ====
values <- as.call(quote(.Deprecated("XXX")))
x <- appendToBody(fun = fun, values = values)
body(x)
#> {
#> .Deprecated("XXX")
#> print("hello world")
#> }
## values: list ====
values <- list(
quote(print("AAA")),
quote(print("BBB"))
)
x <- appendToBody(fun = fun, values = values)
body(x)
#> {
#> print("AAA")
#> print("BBB")
#> print("hello world")
#> }