Optional arguments in S4 generics

℡╲_俬逩灬. 提交于 2019-12-04 14:18:20

A generic can limit the number of arguments on which dispatch actually occurs (using the 'signature' argument to setGeneric) (e.g., 'skip' and 'limit' will never be anything other than a numeric, so should not be included in dispatch. It's not unusual for optional arguments to appear after '...' (they need to be spelled in full, instead of being matched by position, but being explicit seems like a good idea here; '...' are needed to allow methods to expose their own additional arguments)

setGeneric("fancy",
    function(x, y, ..., z=1, verbose=TRUE) standardGeneric("fancy"),
    signature=c("x", "y"))

One can also write methods for class 'ANY', although that's a pretty confident promise. Probably it would be better for RMongo to use the generics from the DBI package.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!