D
Daniel Finnie
Hi all,
Does anyone know how to invoke super so that it passes no arguments to
the superclass' method?
For example:
class A
def initialize
puts "making an A"
end
end
class B < A
def initialize var
puts "making a #{var} b"
super
end
end
B.new "great"
results in:
making a great b
/tmp/super.rb:10:in `initialize': wrong number of arguments (1 for 0)
(ArgumentError)
from /tmp/super.rb:10:in `initialize'
from /tmp/super.rb:14:in `new'
from /tmp/super.rb:14
Because calling super with no arguments causes the method's arguments
to be repeated. How do I stop this? Temporarily, I stuck a *args on
class A's initialize method but that is not pretty!
Dan
Does anyone know how to invoke super so that it passes no arguments to
the superclass' method?
For example:
class A
def initialize
puts "making an A"
end
end
class B < A
def initialize var
puts "making a #{var} b"
super
end
end
B.new "great"
results in:
making a great b
/tmp/super.rb:10:in `initialize': wrong number of arguments (1 for 0)
(ArgumentError)
from /tmp/super.rb:10:in `initialize'
from /tmp/super.rb:14:in `new'
from /tmp/super.rb:14
Because calling super with no arguments causes the method's arguments
to be repeated. How do I stop this? Temporarily, I stuck a *args on
class A's initialize method but that is not pretty!
Dan