env_get

0th

Percentile

Get an object in an environment

env_get() extracts an object from an enviroment env. By default, it does not look in the parent environments. env_get_list() extracts multiple objects from an environment into a named list.

Usage
env_get(env = caller_env(), nm, inherit = FALSE)

env_get_list(env = caller_env(), nms, inherit = FALSE)

Arguments
env

An environment or an object bundling an environment, e.g. a formula, quosure or closure.

nm, nms

Names of bindings. nm must be a single string.

inherit

Whether to look for bindings in the parent environments.

Value

An object if it exists. Otherwise, throws an error.

Aliases
  • env_get
  • env_get_list
Examples
library(rlang) # NOT RUN { 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) # }
Documentation reproduced from package rlang, version 0.2.0, License: GPL-3

Community examples

Looks like there are no examples yet.