Skip to content
Justice Tech School

Inheritance and super

< inherits. super calls the parent method.

Example
class Animal
  def speak = "..."
end
class Cat < Animal
  def speak = super + " meow"
end
puts Cat.new.speak, Cat.superclass, Cat.ancestors.first(2).inspect

Result

... meow
Animal
[Cat, Animal]

Exercise

Inherit.

class Cat  Animal

Quiz Test

What does super do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.