Patrick Gundlach
10/22/2003 7:42:00 PM
Dear Ruby Hackers,
another newbee question:
--------------------------------------------------
class A
def initialize (a,b)
# do something complicated:
puts a + b
end
end
class B < A
def initialize
super.new ("Hello", "world") # line 12
end
end
B.new
--------------------------------------------------
Gives me
-:12:in `initialize': wrong # of arguments(0 for 2) (ArgumentError)
from -:12:in `initialize'
from -:16:in `new'
from -:16
I can do something like this:
--------------------------------------------------
class B < A
alias :supernew :initialize
def initialize
supernew ("Hello", "world")
end
end
--------------------------------------------------
But is this the way to go? Calling the initialize method for a super
class is common in OOP, isn't it?
Patrick
--
You are your own rainbow!