I have the following code:
protocol MyProtocol {
// Are the following 2 declarations necessary?
var myProperty: Int { get }
func myFunc()
}
extension MyProtocol {
var myProperty: Int {
return 1
}
func myFunc() {
print("hello")
}
}
Since I am providing default implementations in the extension, I can access either the property or the function from a conforming class even when they're not declared in the protocol body. Is it necessary therefore to declare the stored property and function in the body of the protocol? Any case where not declaring them will pose an issue? Thanks for the pointers.