Created
July 17, 2020 23:49
-
-
Save leopic/3459533ff8874f8ed8bda89cb933b588 to your computer and use it in GitHub Desktop.
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 requiredMethod() -> Void | |
func optionalMethod() -> Void | |
} | |
extension MyProtocol { | |
func optionalMethod() -> Void {} // Default implementation | |
} | |
struct AStructThatConformsToMyProtocol:MyProtocol { | |
func requiredMethod() -> Void { | |
// this is mandatory | |
} | |
} | |
let myInstance = AStructThatConformsToMyProtocol() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment