Explain super keyword?

  • Calls the method of the same name from parent class.
class Animal
  def speak
"Animal sound"
end end class Dog < Animal def speak
super + " Woof!"
end end puts Dog.new.speak # Output: "Animal sound Woof!"

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *