swift编程语言中的相关类型是什么?它们用于什么?
@H_301_19@根据swift编程语言书:
When defining a protocol,it is sometimes useful to declare one or
more associated types as part of the protocol’s definition. An
associated type gives a placeholder name (or alias) to a type that is
used as part of the protocol. The actual type to use for that
associated type is not specified until the protocol is adopted.
Associated types are specified with the typealias keyword.
上面的文字对我来说不是很清楚.如果您可以通过示例解释相关类型,那将会有很大帮助.
另外,为什么将关联类型声明为协议定义的一部分有用呢?