An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
100 Days of Swift - Day 11
Continuation of Hacking With Swift 100 Days of Swift
Day 11 - Protocols
(Maybe just call them interfaces?)
So protocols are in swift what interfaces are in any other language, but here protocols are a bit on steroids, and here is why. You have your usual stuff around them, access modifier, define the behavior of whoever implements them, you can abstract the concrete class by using the protocol in a parameter, etc.
What makes them powerful is the fact that they serve sort of an abstract interface when matched with Extensions, these allow you to modify data types (structs and protocols) to add a desire behavior and at the same time when paired with protocols it helps them have a default functionality, so whenever a class implements the protocol it doesn't have to build the body of all the protocol member's (so an abstract class).
Man this journey makes my brain hurts a bit.
Original Link: https://dev.to/davjvo/100-days-of-swift-day-11-176p
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To