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
protocol MyProtocol { | |
func doThe(thing: String) | |
} | |
extension MyProtocol { | |
func doThe(thing: String = "") { | |
print("protocol") | |
} | |
} | |
class MyImplementation: MyProtocol { | |
func doThe(thing: String = "") { | |
print("implementation") | |
} | |
} | |
class MyThing { | |
let myProtocol: MyProtocol | |
init(myProtocol: MyProtocol) { | |
self.myProtocol = myProtocol | |
} | |
func doTheThing() { | |
myProtocol.doThe(thing: "") // prints "implementation" | |
myProtocol.doThe() // prints "protocol" | |
} | |
} | |
MyThing(myProtocol: MyImplementation()).doTheThing() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment