Inheritance allows classes to define specific behaviour based on an existing class.
class Animal def say_hello 'Meep!' end def eat 'Yumm!' end end class Dog < Animal def say_hello 'Woof!' end end spot = Dog.new spot.say_hello # 'Woof!' spot.eat # 'Yumm!'
In this example:
Animal, making it a Subclass.
Doggains both the
say_hellomethod with different functionality.