Swift Language: Struct Vs Class Vs Protocol

At this point cat and dog both refer to the same Object in memory, there is only one Animal object
At this point, there are two independent Animal objects in memory and modifying one doesn’t affect the other.
  • Is a blueprint that a class or struct follows
  • Is a communication contract for unrelated objects to rely on
  • Defines methods and values

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store