Skip to content

Instantly share code, notes, and snippets.

@luckydev
Created April 10, 2011 07:00
Show Gist options
  • Save luckydev/912116 to your computer and use it in GitHub Desktop.
Save luckydev/912116 to your computer and use it in GitHub Desktop.
explicitly forward arguments
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