Created
November 9, 2018 17:11
-
-
Save fewlinesofcode/d7bd1f0b6a4353f9f7279ceb3b1eda19 to your computer and use it in GitHub Desktop.
Playground code for the article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol CustomProtocol { | |
associatedtype AssociatedType | |
func foo(argument: AssociatedType) | |
} | |
//let array = [CustomProtocol]() // Gives error: Protocol 'CustomProtocol' can only be used as a generic constraint because it has Self or associated type requirements | |
public struct AnyCustomProtocol<T>: CustomProtocol { | |
func bar() -> T { | |
fatalError("Needs implementation") | |
} | |
func foo(argument: T) { | |
} | |
} | |
let array = [AnyCustomProtocol<Any>]() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment