Consider the following:
A = R6::R6Class("ClassA")
B = R6::R6Class("ClassB")
`+.ClassA` = function(o1,o2) o1 #Trivial Example, Usually do something
`+.ClassB` = function(o1,o2) o1 #Trivial Example, Usually do something
a = A$new()
b = B$new()
a + b
Which throws an error:
Warning: Incompatible methods ("+.ClassA", "+.ClassB") for "+"
Error in a + b : non-numeric argument to binary operator
How can the above be resolved, so both A
and B
can overload the +
operator, and be added together.