Hello, I am trying to improve my skill on S4 classes. But there's something strange (to me) happening with "initialize" methods. This is probably a normal behaviour... but... something is unclear in my mind
I declare two classes, namely "A", and "B", which has a slot of type A. The class "A" has an initialize method. What I do not understand is that the Class A initialize-method is run when defining the Class B Here is the code . > setClass("A",representation=representation(a="numeric")) > setMethod("initialize","A",function(.Object){cat("*** initialize A ***\n");return(.Object)}) [1] "initialize" > > > setClass("B",representation=representation(a="A",b="numeric")) > setClass("B",representation=representation(a="A",b="numeric")) *** initialize A *** > Actually I do not understand the line *** initialize A ***. What the need to initialize A just in a (simple) definition of the class B? Thanks in advance Franck [[alternative HTML version deleted]] ______________________________________________ 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.