我试图创建简单的协议:斯威夫特协议属性设置<Self>
protocol Groupable
{
var parent: Self? { get }
var children: Set<Self> { get }
}
但children
财产不能编译,因为:Type 'Self' does not conform to protocol 'Hashable'
。
有没有什么办法,以确保Self
是Hashable
?或者使用associatedtype
任何其他的办法解决这个,例如?
哦......那是太容易了。我准备好了先进的快速协议课程。我想我现在应该回到幼儿园。 – tzaloga