如果我是第一次运行以下代码,我会收到有关set方法的警告:
Warning message:
In getPackageName(environment(fdef)) :
Create package name, ‘2013-09-18 09:29:59’, if nothing there
B.getFields<-function(keys){
vars<-mget(names(.refClassDef@fieldClasses), envir = attr(.self, ".xData"))
return(vars[keys])
}
B<-setRefClass(Class = "B"
,fields = list(var1 = "character")
,methods = list(getFields=B.getFields
,initialize=function(...) {
usingMethods("getFields")
callSuper(...)
}
)
)
setGeneric("getFields", function(object, ...) standardGeneric("getFields"))
setMethod(getFields, "list", function(object, ...) lapply(object,getFields,...))