Swift Language Classes Classes and Multiple Inheritance

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Swift does not support multiple inheritance. That is, you cannot inherit from more than one class.

class Animal { ... }
class Pet { ... }

class Dog: Animal, Pet { ... } // This will result in a compiler error.

Instead you are encouraged to use composition when creating your types. This can be accomplished by using protocols.



Got any Swift Language Question?