You probably don't want @children
to be an array. With a dim
attribute of length 1, it's essentially the same as a vector, and you lose the ability to distinguish different people's children. Consider making this slot a list instead.
setClass("person",
representation(name="character", age="numeric", children = "list"))
person = new("person", name="John", age=40, children = list(kids1))
person@children
people = new("person", name=c("John", "Fred"), age=c(40, 20),
children = list(kids1, kids2))
people[1]