Skip to content

Instantly share code, notes, and snippets.

@d-plaindoux
Created June 14, 2017 05:20
Show Gist options
  • Save d-plaindoux/f679e8bf89625f2d65aa1b6dd4c9572e to your computer and use it in GitHub Desktop.
Save d-plaindoux/f679e8bf89625f2d65aa1b6dd4c9572e to your computer and use it in GitHub Desktop.
Swift deferred object creation using associated type
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