Examples for 'rlang::env_unbind'


Remove bindings from an environment

Aliases: env_unbind

Keywords:

### ** Examples

env <- env(foo = 1, bar = 2)
env_has(env, c("foo", "bar"))
 foo  bar 
TRUE TRUE 
# Remove bindings with `env_unbind()`
env_unbind(env, c("foo", "bar"))
env_has(env, c("foo", "bar"))
  foo   bar 
FALSE FALSE 
# With inherit = TRUE, it removes bindings in parent environments
# as well:
parent <- env(empty_env(), foo = 1, bar = 2)
env <- env(parent, foo = "b")

env_unbind(env, "foo", inherit = TRUE)
env_has(env, c("foo", "bar"))
  foo   bar 
FALSE FALSE 
env_has(env, c("foo", "bar"), inherit = TRUE)
 foo  bar 
TRUE TRUE 

[Package rlang version 1.1.4 Index]