Hi,
New to this list, and glad I found R5 which si a great improvement to R for my work. Something seems odd anyway, when I do a setRefClass, the initialize method execute at the class definition.
I would like it to execute only when an instance is created.
How can I do that? I found no way to test if the code execution is when the class definition happens or when a $new instance is created.
Thanks for your help.
For example my class definition looks like this :

mongoDbUser = setRefClass("mongoDbUser",
    fields = list(
    auth = "logical",
    host = "character",
        username = "character",
    password = "character",
        db = "character",
    connector = "mongo"
    ),
  methods = list(
    initialize = function(auth,host,username,password,db,connector){
      print("initialization")
    }
  )
)

If I execute this code, it says "initialization", but it shouldn't, I created no instance, right??
I would like "initialization" to appear only when I do :
mongoDbUser$new(...)

______________________________________________
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.

Reply via email to