env_has

0th

Percentile

Does an environment have or see bindings?

env_has() is a vectorised predicate that queries whether an environment owns bindings personally (with inherit set to FALSE, the default), or sees them in its own environment or in any of its parents (with inherit = TRUE).

Usage
env_has(env = caller_env(), nms, inherit = FALSE)
Arguments
env

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

nms

A character vector containing the names of the bindings to remove.

inherit

Whether to look for bindings in the parent environments.

Value

A logical vector as long as nms.

Aliases
  • env_has
Examples
# NOT RUN {
parent <- child_env(NULL, foo = "foo")
env <- child_env(parent, bar = "bar")

# env does not own `foo` but sees it in its parent environment:
env_has(env, "foo")
env_has(env, "foo", inherit = TRUE)
# }
Documentation reproduced from package rlang, version 0.1.6, License: GPL-3

Community examples

Looks like there are no examples yet.