有沒有辦法只列出參考類的那些方法,即在類定義中定義的明確(與那些由「系統類」 refObjectGenerator
或envRefClass
)?僅列出明確定義的方法
Example <- setRefClass(
Class="Example",
fields=list(
),
methods=list(
testMethodA=function() {
"Test method A"
},
testMethodB=function() {
"Test method B"
}
)
)
您目前通過調用$methods()
方法得到什麼(見?setRefClass
):
> Example$methods()
[1] "callSuper" "copy" "export" "field" "getClass"
[6] "getRefClass" "import" "initFields" "show" "testMethodA"
[11] "testMethodB" "trace" "untrace" "usingMethods"
我正在尋找:
> Example$methods()
[1] "testMethodA" "testMethodB"
謝謝,那也是我當前的解決方法。但是我想知道是否有更多的內置內容,因爲我不喜歡爲了明確比較而創建虛擬類的想法。 – Rappster
我已經添加了第二種方法。 –
哇,一些真棒'過濾器'功夫在那裏! :-)之前從未使用過該功能,但看起來非常強大!謝啦。 – Rappster