
Last chance! 50% off unlimited learning
Sale ends in
env_unbind()
is the complement of
env_bind()
. Like env_has()
, it ignores the
parent environments of env
by default. Set inherit
to
TRUE
to track down bindings in parent environments.
env_unbind(env = caller_env(), nms, inherit = FALSE)
env()
. If missing, the environment of the current
evaluation frame is returned.env
, with its associated
environment modified in place.
data <- stats::setNames(letters, letters)
env_bind(environment(), data)
env_has(environment(), letters)
# env_unbind() removes bindings:
env_unbind(environment(), letters)
env_has(environment(), letters)
# With inherit = TRUE, it removes bindings in parent environments
# as well:
parent <- new_env(empty_env(), list(foo = "a"))
env <- new_env(parent, list(foo = "b"))
env_unbind(env, "foo", inherit = TRUE)
env_has(env, "foo", inherit = TRUE)
Run the code above in your browser using DataLab