It seems that if we create a class B
that inherits from class A
, A
's constructor is called when B
is being created. This leads to the following problem - A
may have a mandatory parameter in its ctor (for use during instantiation), and so running the following:
A <- setRefClass("A",
methods = list(
initialize = function(mandatoryArg) {
print(mandatoryArg)
}
)
)
B <- setRefClass("B", contains = "A")
I get the error
Error in .Object$initialize(...) :
argument "mandatoryArg" is missing, with no default
This seems very strange - why is this happening and what can I do about this?