Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print(var_1)
- print("world")
- print(var_2)
- print("hello")
- print("world")
- print("goodbye")
- esubstitute <- function(expr, envir) do.call("substitute", list(expr, envir))
- do_something <- function(todo, envir = parent.frame()) {
- cat(
- paste(
- deparse(esubstitute(todo, envir)),
- collapse = "n"
- )
- )
- }
- nested_do <- function(envir = parent.frame()) {
- var_2 <- "goodbye"
- do_something({
- print(var_1)
- print("world")
- print(var_2)
- }, envir)
- }
- var_1 <- "hello"
- nested_do()
- [1] "hello"
- [1] "world"
- [1] "goodbye"
- "goodbye">
Add Comment
Please, Sign In to add comment