# When you define a method in a class, you can redefine that method in a derived class,
# and that's what overriding is all about - redefining a method in a derived class.
class Animal
def initialize(color)
@color = color
end
def get_color
return @color
end
end
class Dog < Animal
def initialize(color)
super(color)
end
def get_color
return "blue"
end
end
dog = Dog.new("brown")
puts "The new dog is " + dog.get_color
|