I didn't see an answer to this and I THINK I sorted it out myself so I
thought I'd post it for anyone who is interested (in using it or correcting
it):
My original question:
Can someone show me how to modify one (R.oo) class's object inside another
(R.oo) class's method? Is that possible with the R.oo package? A quick
example or reference to an example would be outstanding...
Solution:
setConstructorS3("Person", function(age) {
  if (missing(age))  age <- NA;
  extend(Object(), "Person",
    .age=age
  )
})
setMethodS3("getAge", "Person", function(this, ...) {
  this$.age;
})
setMethodS3("setAge", "Person", function(this, newAge, ...)
{
  if (!is.numeric(newAge))
    throw("Age must be numeric: ", newAge);
  if (newAge < 0)
    throw("Trying to set a negative age: ", newAge);
  this$.age <- newAge;
})
setConstructorS3("AgeMultiplier", function() {
  extend(Object(), "AgeMultiplier",
    .age=NA,
    .age_multiplied=NA
  )
})
setMethodS3("doMultiply", "AgeMultiplier",
function(this,per_obj, ...) {
  this$.age_multiplied =  per_obj$age  * 2;
  per_obj$age = this$.age_multiplied;
})
Use example:
p1 <- Person(67)
am1 =  AgeMultiplier()
am1$doMultiply(p1)
p1$age  # 134
On Tue, Aug 23, 2011 at 8:22 AM, Ben qant <ccquant@gmail.com> wrote:
> Can someone show me how to modify one (R.oo) class's object inside
another
> (R.oo) class's method? Is that possible with the R.oo package? A quick
> example or reference to an example would be outstanding...
>
> Thanks,
>
> Ben
>
	[[alternative HTML version deleted]]