s4 - setMethod for two different object signature in R -


how make using 1 setmethod function section same in following 2 line codes? signature("triangle|square"). thank you.

setmethod("sides", signature("triangle"), function(object) 3) setmethod("sides", signature("square"), function(object) 3) 

the usual approach is

.sides_body = function(object) 3 setmethod("sides", "triangle", .sides_body) setmethod("sides", "square", .sides_body) 

unless there class relationship , definition same across classes

setclass("shape") setclass("triangle", contains="shape") setclass("square", contains="shape") setclass("circle", contains="shape") setmethod("sides", "shape", function(boject) 3) setmethod("sides", "circle", function(object) inf) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -