It is possible to force the type parameters of a generic class to implement a protocol, for example, Equatable
<Type: Equatable>TypeTypeTypeType
Whenever we create a new MyGenericClass
, the type parameter has to implement the Equatable
protocol (ensuring the type parameter can be compared to another variable of the same type using ==
)
DoubleString[Int]Int