Created
April 10, 2011 06:57
-
-
Save luckydev/912113 to your computer and use it in GitHub Desktop.
to demonstrate what super keyword does in ruby
This file contains 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
module A | |
def say_hi(a,b,c) | |
puts "Hi, from [A] module. Numbers - #{a} #{b} #{c}" | |
end | |
end | |
class B | |
include A | |
def say_hi(a,b,c) | |
puts "B is saying Hi.. " | |
# writing super, will forward all the arguments to the method above | |
super | |
end | |
end | |
b = B.new | |
b.say_hi(1,2,3) | |
#output | |
B is saying Hi.. | |
Hi, from [A] module. Numbers - 1 2 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment