![So here are the benefits of inheritance: • Unlike composi...](https://readwise-assets.s3.amazonaws.com/static/images/article2.74d541386bbf.png)
Josh BeckmanSo here are the benefits of inheritance:
• Unlike composition, you can pass the subclass into functions expecting the parent class. • Unlike interfaces, you can reuse code from the parent class in the child class.
So, here’s when you want to use inheritance: when you need to instantiate both the parent and child classes and pass them to the same functions. That’s it. That’s the use case.
✉️Hillel WayneWhen to Prefer Inheritance to Composition