Just wondered about this curious behaviour. I'm trying to learn about
classes. Basically setMethod works the first time, but does not seem to
work the second time.
Faheem.
*************************************************************************
setClass("foo", representation(x="numeric"))
bar <- function(object)
{
return(0)
}
bar.foo <- function(object)
{
print([EMAIL PROTECTED])
}
setMethod("bar", "foo", bar.foo)
bar(f)
# bar(f) gives 1.
bar <- function(object)
{
return(0)
}
bar.foo <- function(object)
{
print([EMAIL PROTECTED])
}
setMethod("bar", "foo", bar.foo)
f = new("foo", x= 1)
bar(f)
# bar(f) gives 0, not 1.
______________________________________________
[email protected] 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.