Open wnagrodzki opened 5 years ago
It is usually not obvious that static dispatch is going to be used. If object implementing MyProtocol delivers it own numberOfItems implementation it is not going to be called. (add an example to show the problem)
MyProtocol
numberOfItems
protocol MyProtocol { func item(at index: Int) -> String } extension MyProtocol { var numberOfItems: Int { return 4 } }
Declare methods added via protocol extension.
protocol MyProtocol { var numberOfItems: Int { get } func item(at index: Int) -> String } extension MyProtocol { var numberOfItems: Int { return 4 } }
It is usually not obvious that static dispatch is going to be used. If object implementing
MyProtocol
delivers it ownnumberOfItems
implementation it is not going to be called. (add an example to show the problem)Declare methods added via protocol extension.