I'm working with a reference class with a few dozen fields. I've set up an initialize()
method that takes a list object in. While some of the fields rely on further computation from list elements, most of the fields are directly assigned from list elements as such:
fieldA <<- list$A
fieldB <<- list$B
I was thinking that it'd be nice to automate this a bit. To give an example in R pseudocode (this example obviously won't work):
for (field in c('A', 'B', 'C', 'D'))
field <<- list[[field]]
I've tried making a few end runs around the <<-
for instance doing something like:
for field in c('A', 'B', 'C', 'D'))
do.call('<<-' c(field, list[[field]]))
but no dice.
My guess is that this sort of behavior simply isn't possible in the current incarnation of reference classes, but thought it might be worth seeing if anyone out in SO land knew of a better way to do this.