Overview - Why inheritance is class-only in Swift
What is it?
Inheritance in Swift means one type can take properties and behaviors from another. However, only classes can inherit from other classes. Structures and enumerations cannot inherit. This design choice helps keep Swift safe and clear about how data and behavior are shared.
Why it matters
Without limiting inheritance to classes, Swift would risk confusing how data is copied and shared. If structs or enums inherited, it could cause unexpected bugs or performance issues. This rule helps developers write safer, more predictable code, especially when working with complex data.
Where it fits
Before this, learners should understand basic Swift types: classes, structs, and enums. After this, they can explore protocols and protocol inheritance, which provide flexible ways to share behavior without class inheritance.