Skip to content

Instantly share code, notes, and snippets.

@lukaszmargielewski
Last active April 25, 2017 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszmargielewski/48fe181264bbc468e1c3b80aec0a6516 to your computer and use it in GitHub Desktop.
Save lukaszmargielewski/48fe181264bbc468e1c3b80aec0a6516 to your computer and use it in GitHub Desktop.
protocol AProtocol {}
protocol ABProtocol: AProtocol {}
struct ABStruct: ABProtocol {}
struct Wrapper<T> {
let object: T
}
extension Array where Element == Wrapper<AProtocol> {
func merge(with otherArray: [Element]) {}
}
let wrapper1: Wrapper<ABProtocol> = Wrapper(object: ABStruct())
let wrapper2: Wrapper<ABProtocol> = Wrapper(object: ABStruct())
let wrappers1 = [wrapper1, wrapper2]
let wrappers2 = [wrapper2, wrapper1]
// Following produces compilation error:
// '[Wrapper<ABProtocol>]' is not convertible to 'Array<Wrapper<AProtocol>>'
let result = wrappers1.merge(to: wrappers2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment