I have 2 protocols. I need the first (NameProtocol) to enforce the Equatable protocol. While another class (BuilderProtocol) has a method that returns the first (NameProtocol).
public protocol NameProtocol : Equatable {
var name: String { get }
}
public protocol BuilderProtocol {
func build() -> NameProtocol?
init()
}
Compiler error: "The Protocol" NameProtocol "can only be used as a general restriction, since it has its own or related requirements like"
I need to return a build () object to return an object corresponding to NameProtocol, and on which I can define ==
Is there any way to make this work?
thank
If using typealias in BuilderProtocol can I make an array declaration work?
public protocol OtherRelatedProtocol {
var allNames : Array<NameProtocol> { get }
}
Conclusion
I will remove Equatable and implement the isEqual method.
public protocol NameProtocol {
func isEqual(nameable: NameProtocol) -> Bool
var name: String { get }
}