Does the environment ever change?

cited from Hadley's book Extended R: Environment

The environment refers to a function and never changes, even if the function moves to another environment.

The following code shows that environment f changed as environment e . So what does it mean that "the environment does not change"?

 f = function() { } environment(f) # <environment: R_GlobalEnv> e = new.env() environment(f) = e environment(f) # <environment: 0x2a01c88> 
+3
source share

Source: https://habr.com/ru/post/1268651/


All Articles