什么是<> (尖括号)对类名在swift? [英] What does <> (angle brackets) do on class names in swift?
本文介绍了什么是<> (尖括号)对类名在swift?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在类声明中,使用<>尖括号和在swift中声明的参数是什么?如:
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> {
}
推荐答案
它使类通用。 Swift标准库没有很多泛型类的例子,但它有一些非常着名的通用结构和枚举:
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
阅读更多关于Genericsin the Swift Programming Language 。
Read more about generics under "Generics" in The Swift Programming Language.
这篇关于什么是<> (尖括号)对类名在swift?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文