Created
April 10, 2011 07:00
-
-
Save luckydev/912116 to your computer and use it in GitHub Desktop.
explicitly forward arguments
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.. " | |
# explicitly forward arguments | |
super(a,b) | |
end | |
end | |
b = B.new | |
b.say_hi(1,2,3) | |
#output | |
B is saying Hi.. | |
su.rb:2:in `say_hi': wrong number of arguments (2 for 3) (ArgumentError) | |
from su.rb:14:in `say_hi' | |
from su.rb:19:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment