Redefining methods of a refClass does not change the methods for
existing instances. I found this somewhat surprising, and also pretty
inconvenient for debugging.
The documentation for reference classes does say that their methods
should be minimalist, which I suppose is partly because of this behavior.
Is there a way around this behavior apart from passing the pieces of the
old instance to the new constructor, or putting all computations in not
class functions?
foo <- setRefClass("foo", methods=list(f=function(x) 3*x))
a <- foo()
a$f(10)
[1] 30
foo <- setRefClass("foo", method=list(f=function(x) 2*x))
a$f(10)
[1] 30
b <- foo()
b$f(10)
[1] 20
Ross Boylan
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.