I want to add a function to all the classes that implement Comparable , such as Int, Float, CGFloat. Here is my code with error reported:
extension Comparable{
func constraintBetween<T: Comparable>(a:T , b: T) -> T{
if self < a {
return a
}else if self > b{
return b
}else{
return self
}
}
}