Constraining Generic Placeholder Types
suggest changeIt 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents