class Person
def initialize(name)
@name = name
end
def name
return @name
end
end
class Doctor < Person
def name
“Dr. “ + super
end
end
That, in short, is how super works. Taken from Beginning Ruby by Peter Cooper.
super
in short calls up the parent class’ instance method.
Advertisement