What is the best way to create a generic method that acts differently depending on the given type without using if statements that check what type is that?
For instance, how to create an Add<T>(T x, T y)
method that returns x + y
if T
is Integer
and x.add(y)
if T
is BigInteger
, without checking if class of T
is BigInteger
or not.