I would like to have a generic function that can use the plus operator on two values.
class funccalc {
func doAdd(x:T,y:T) -> T {
ret
Have you tried using the protocol AdditiveArithmetic
?
https://developer.apple.com/documentation/swift/additivearithmetic
Looks like thats exactly what you are looking for. That protocol has the method:
static func + (Self, Self) -> Self
Using your that protocol your method becomes:
class funccalc {
func doAdd(x:T,y:T) -> T {
return x + y
}
}