Learn R Programming

assertive (version 0.2-6)

assert_is_binding_locked: Is the binding of a variable locked?

Description

Check to see if the binding of a variable is locked (that is, it has been made read-only).

Usage

assert_is_binding_locked(x)

is_binding_locked(x, env = if (is_scalar(e <- find(.xname))) as.environment(e)
  else parent.frame(), .xname = get_name_in_parent(x))

Arguments

x
Input to check. (Unlike bindingIsLocked, you can pass the variable itself, rather than a string naming that variable.)
env
Environment to check where binding had been locked.
.xname
Not intended to be used directly.

Value

  • TRUE or FALSE, depending upon whether or not the binding is locked in the specified environment. assert_is_binding_locked returns nothing but throws an error if the corresponding is_* function returns FALSE.

See Also

bindingIsLocked, which this wraps, find for how the environment is guessed. If the returns a single environment, that is used. Otherwise the parent environment is used (as determined with parent.frame).

Examples

Run this code
is_binding_locked(a_non_existent_variable)
x <- 1:10
is_binding_locked(x)
lockBinding("x", parent.frame())
is_binding_locked(x)
unlockBinding("x", parent.frame())
is_binding_locked(x)

Run the code above in your browser using DataLab