Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 15, 2022 12:17 pm GMT

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

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To