[R] Methods dispatch and inheritance R.oo

From: Yuri Volchik <yuri.volchik_at_gmail.com>
Date: Wed, 05 Nov 2008 02:18:17 -0800 (PST)

Hi to all members, i have a question about class inheritance and methods using R.oo package:
I have the following code and it doesn't work, guess i'm doing smth wrong and there is nothing in the help.

library(R.oo)

setConstructorS3("ClassA", function(A=15) {   extend(Object(), "ClassA",
    .size = A
  );
})

setMethodS3("print", "ClassA", function(this,...) {   print(paste('Class A:',this$.size));
})

objA<-ClassA();
objA

[1] "Class A: 15"

setConstructorS3("ClassB", function(B=15) {   extend("ClassA", "ClassB",
    .size2 = B
  );
})

setMethodS3("print", "ClassB", function(this,...) {   print(paste('Class B:',this$.size2));
})

objB<-ClassB();
objB

Error in this$.size2 : $ operator is invalid for atomic vectors

-- 
View this message in context: http://www.nabble.com/Methods-dispatch-and-inheritance-R.oo-tp20339090p20339090.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 05 Nov 2008 - 10:47:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 06 Nov 2008 - 06:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive