Hello, I am working with a reference class:

Foo <- setRefClass("Bar",
  fields = list( a = "numeric"),
  methods = list( baz = function( xa ) a <<- xa )
)
x <- Foo$new()
x$baz(2)
x$a
y <- new("Bar")
y$baz(4)
y$a

But that might be confusing, since new(Foo) does not work and neither does 
Bar$new() (which is both clear to me but -- maybe -- not to the user). So my 
idea was to:

Bar <- setRefClass("Bar",
  fields = list( a = "numeric"),
  methods = list( baz = function( xa ) a <<- xa )
)
x <- Bar$new()
x$baz(2)
x$a
y <- new("Bar")
y$baz(4)
y$a

However, this is not the way it is usually done (e.g., with Rcpp modules), why 
not? Thanks, Sören

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

Reply via email to