I've just learned about extensions and I was wondering, there was an example about extending a protocol. For example, let's say we have the protocol:
protocol CanFly {
func canFly()
}
which allows all the classes who can fly to basiclly to fly. Now lets say that we use extension to extend the protocol, and we do:
extension CanFly {
func canEat() {
print("I can eat")
}
}
What is the purpose of that if we can just add that func canEat
to our protocol? More of those protocols are like an abstract struct so why would we add a func with a body to it?
- just wanna say if I've made a mess im sorry for that lol, just want to clear out few things about extension <3