[英]What does <> (angle brackets) do on class names in swift?
In a class declaration what is the use of <> angle brackets and the parameters declared inside in swift? 在类声明中,<>尖括号和在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: Swift标准库没有很多泛型类的示例,但是它具有一些非常著名的泛型结构和枚举:
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 . 在Swift编程语言的 “泛型”下阅读有关泛型的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.