Is something like this possible in Swift?
protocol SpeaksGerman {
func speakGerman()
}
protocol SpeaksFrench {
func speakFrench()
}
protocol HasGermanSpeaker {
var speaker: SpeaksGerman! {get}
}
protocol HasFrenchSpeaker {
var speaker: SpeaksFrench! {get}
}
class IHaveAPolyglotSpeaker: HasGermanSpeaker {
var speaker: (SpeaksGerman & SpeaksFrench)!
}
Since var speaker
is declared as conforming to both SpeaksGerman
and SpeaksFrench
I'd expect IHaveAPolyglotSpeaker
to conform to any of the HasGermanSpeaker
or HasFrenchSpeaker
protocols.