What does <> (angle brackets) do for class names in swift?

Does the class declaration use <> angle brackets and parameters declared internally in swift? For example:

public class ClassName<T: Comparable> {


}
+4
source share
1 answer

This makes the class common. There are no examples of common classes in the standard Swift library, but it has very well-known common structures and enumerations:

public struct Array<Element> : CollectionType, MutableCollectionType, _DestructorSafeContainer

public struct Dictionary<Key : Hashable, Value> : CollectionType, DictionaryLiteralConvertible

public enum Optional<Wrapped> : _Reflectable, NilLiteralConvertible

Learn more about generics in the Generics section of Swift Programming .

+3
source

Source: https://habr.com/ru/post/1620661/


All Articles