Constructor overriding
- by demas
I have a library with a class:
class One
def initialize
puts "one initialize"
end
end
I can not change the declaration and difinition of this class.
I need create new class with my own constructor. Like this:
class Two < One
def initialize(some)
puts some
super
end
end
one = One.new
one = Two.new("thing")
But when I launch code I got error:
[[email protected]][~/temp]% ruby test.rb
one initialize
thing
test.rb:10:in `initialize': wrong number of arguments (1 for 0) (ArgumentError)
from test.rb:15:in `new'
from test.rb:15:in `<main>'