bind_fn_2_env {bandicoot} | R Documentation |
Bind functions of the current environment to a target environment
Description
This function is equivalent to environment(fn) <- env
. Hence functions
must bind to names.
Usage
bind_fn_2_env(env, ...)
Arguments
env |
Environment. |
... |
Functions. |
Details
Pass character function names to ...
will cause error.
Value
No return value, called for side effects.
Examples
# Access the associated environment inside a function
self <- NULL
e <- new.env()
# The associated environment needs to have a reference to itself
e$self <- e
e$show_self <- function() return(self)
# The function can only access the global variable `self`
e$show_self()
# Bind the function to the environment `e`
bind_fn_2_env(env = e, e$show_self)
# Both point to the same environment
e$show_self()
e
[Package bandicoot version 1.0.0 Index]