I've been trying to use methods for reference classes via the notation "[[...]]" (X[["doSomething"]] rather than X$doSomething), but it failed to work. However, I did find that if you use the usual "$" notation first, "[[...]]" can be used afterwards. The following simple example illustrates the point: > setRefClass("Number", + fields = list(+ value = "numeric"+ ),+ > methods = list(+ addOne = function() {+ value <<- value + 1+ }+ > )+ )> X <- new("Number", value = 1)> X[["value"]][1] 1 > X[["addOne"]]()Error: attempt to apply non-function> class(X[["addOne"]]) # > NULL[1] "NULL" > class(X$addOne)[1] "refMethodDef"attr(,"package")[1] "methods" > X[["addOne"]]()> X[["value"]][1] 2> class(X[["addOne"]])[1] > "refMethodDef"attr(,"package")[1] "methods" Is this a bug? Chad Goymer [[alternative HTML version deleted]]
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel