2013-06-28 59 views
6

是否有任何官方的方式來顯示R5中R5類生成器對象的類方法的定義?用R5生成器對象顯示類方法的定義

> cls <- setRefClass("cls", methods = list(f1 = function() {1})) 
> 
> # of course we can get the definition via the instance 
> a1 <- new("cls") 
> a1$f1 
Class method definition for method f1() 
function() 
{ 
    1 
} 
<environment: 0x101d5d3f0> 
> 
> # but how to get the difinition via the generator object, i.e., cls? 
> cls$f1 
Error in envRefInferField(x, what, getClass(class(x)), selfEnv) : 
    ‘f1’ is not a valid field or method name for reference class 「refGeneratorSlot」 
> 
> # here is a workaround, but probably unofficial and no warranty for future behavior 
> [email protected]$f1 
Class method definition for method f1() 
function() 
{ 
    1 
} 

回答

相關問題