suppose I have a Reference class definition in R which has fields which itself are reference classes:
A <- setRefClass("A", fields = list(aVar = "numeric"))
B <- setRefClass("B", fields = list(bVarOne = "numeric", bVarTwo = "ANY"))
myBinst <- B$new(bVarOne = 10, bVarTwo = A$new(aVar = 5))
str(myBinst)
Reference class 'B' [package ".GlobalEnv"] with 2 fields
$ bVarOne: num 10
$ bVarTwo:Reference class 'A' [package ".GlobalEnv"] with 1 field
..$ aVar: num 5
..and 12 methods.
and 12 methods.
Reference class instances can refer to themselves with .self, could they refer to an instance of a reference class that contains them as a field i.e. in this example, can the instance of A contained within the instance of B refer to B? If so, how can I do this?
Thanks, Ben.