In a class declaration what is the use of <> angle brackets and the parameters declared inside in swift? Like as:
public class ClassName<T: Comparable> {
}
In a class declaration what is the use of <> angle brackets and the parameters declared inside in swift? Like as:
public class ClassName<T: Comparable> {
}
It makes the class generic. The Swift standard library doesn't have a lot of examples of generic classes, but it has some very well-known generic structs and enums:
public struct Array<Element> : CollectionType, MutableCollectionType, _DestructorSafeContainer
public struct Dictionary<Key : Hashable, Value> : CollectionType, DictionaryLiteralConvertible
public enum Optional<Wrapped> : _Reflectable, NilLiteralConvertible
Read more about generics under “Generics” in The Swift Programming Language.