Created
June 14, 2017 05:20
-
-
Save d-plaindoux/f679e8bf89625f2d65aa1b6dd4c9572e to your computer and use it in GitHub Desktop.
Swift deferred object creation using associated type
This file contains hidden or 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
protocol A { | |
associatedtype E | |
func new() -> E? | |
} | |
protocol C { | |
init() | |
} | |
class B<R:C> : A { | |
typealias E = R | |
func new() -> E? { | |
return E() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment