I should write a tutorial or something.
Here’s how you create a protocol in Swift.
And here’s how you use it.
So, why would we want to use protocols? Well, if you are writing some code that only requires the interface provided by the protocol, you can ignore the specifics of the struct/class that implements it. So, quickly, we’ll add a second type that conforms to the protocol.
Now, if we have a function that does some action particular to the name and age of an object, we can be less specific than either Dog or Alligator and just use Animal.
That’ll do, pig.