This question already has an answer here:
import Foundation
public func sine <T: FloatingPoint > (_ x: T ) -> T{
return sin(x)
}
// Error: Cannot invoke 'sin' with an argument list of type '(T)'
Is there a way around this? Many thanks.
You can make a sin method that accepts FloatingPoint type also as follow:
Another option is adding a method or a computed property extension to FloatingPoint type as follow: