2011-09-03

super in Ruby

<code>

class Person

def initialize(name)

@name = name

end


def name

return @name

end

end


class Doctor < Person

def name

“Dr. “ + super

end

end

</code>


That, in short, is how super works. 

1 comments:

Alex Dissing said...

Interesting. I'm a stutterer guy practicing my writing. http://alexdissing.blogspot.com/

Copyright

All rights reserved © 2002-2010.