Dear all,

I have a function "fn" with its own environment, i.e.

env <- environment(fn)

and env is not .GlobalEnv. And another function

getValue <- function(x) environment(x)$mylist

which returns the list object "mylist" which is in "env". If I want to modify "mylist", I could write

'getValue<-' <- function(x, value) { environment(x)$mylist <- value}

which gives not the desired result, e.g.

getValue(fn)[[1]] <- 3

will set the first list entry of "mylist" to 3. But then "fn" will also be 3!

environment(fn)$mylist[[1]] <- 3

does set the list entry correctly while keeping "fn". What's the difference?

Cheers,
Daniel

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to