Examples for 'rlang::env_get'


Get an object in an environment

Aliases: env_get env_get_list

Keywords:

### ** Examples

parent <- child_env(NULL, foo = "foo")
env <- child_env(parent, bar = "bar")

# This throws an error because `foo` is not directly defined in env:
# env_get(env, "foo")

# However `foo` can be fetched in the parent environment:
env_get(env, "foo", inherit = TRUE)
[1] "foo"
# You can also avoid an error by supplying a default value:
env_get(env, "foo", default = "FOO")
[1] "FOO"

[Package rlang version 1.1.4 Index]