Created
March 25, 2015 12:09
-
-
Save ihower/9ffe9b86ef49d104fc12 to your computer and use it in GitHub Desktop.
ruby super
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parent | |
def hi(name) | |
puts "I'm parent" | |
puts "Hi, #{name}" | |
end | |
end | |
class Child < Parent | |
def hi | |
puts "I'm child" | |
super("John") | |
end | |
end | |
x = Child.new | |
x.hi | |
#I'm child | |
#I'm parent | |
#Hi, John |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment