Skip to content

Instantly share code, notes, and snippets.

@luckydev
Created April 10, 2011 06:59
Show Gist options
  • Save luckydev/912115 to your computer and use it in GitHub Desktop.
Save luckydev/912115 to your computer and use it in GitHub Desktop.
explicitly putting parenthesis to 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 putting parenthesis - this will send no arguments
super()
end
end
b = B.new
b.say_hi(1,2,3)
#output
B is saying Hi..
super.rb:2:in `say_hi': wrong number of arguments (0 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