Whether I do:
protocol SomeProtocol{}
extension SomeProtocol {
func sayHi(toUser user: String) {
print("Hi \(user)")
}
OR
protocol SomeProtocol{
func sayHi(toUser user: String)
}
extension SomeProtocol {
func sayHi(toUser user: String) {
print("Hi \(user)")
}
I can conform this protocol in my class:
class MyClass: SomeProtocol {
sayHi(toUser: "Minion")
}
Output will be: Hi Minion, whether I use approach 1 or 2. What is the difference of adding vs not adding definition of a function in my protocol?