I think I will send my answer, I will assign the class 'IAddable' for both R6 prototypes (sort of like declaring an interface in other languages)
A = R6::R6Class(c("ClassA","IAddable")) B = R6::R6Class(c("ClassB","IAddable"))
Then we can assign one overloaded statement that will be called by all objects that inherit from this declaration of the interface class.
`+.IAddable` = function(o1,o2) o1 #Trivial Example, Usually do something
This works as expected:
a = A$new() b = B$new() a + b
source share