From: Daniel Kelley Date: 2004-01-23T23:19:58+09:00 Subject: Re: [BEGINNER] Usage of 'super' Michael Weller writes: > ts schrieb: > > > Just write it like this > > > >M> class B < A > >M> def initialize(x, y) > >M> super > > > > super() # call super with no args > > > >M> @myX = x > > > > > > > That doesn't do the trick (btw: super is different from super()?). I should. I just checked with 1.6.7 and 1.8.0 with: (r1.rb) class A def initialize puts 'Class A init' @time = Time.new #here the error happens #inits some instance variables end end class B < A def initialize(x, y) super() @myX = x @myY = y end end (r2.rb) require 'r1.rb' b = B.new('sth', 'anotherSth') puts b.to_s (test) 1024>ruby r2.rb Class A init # 1025>/usr/local/src/ruby-1.6.7/ruby r2.rb Class A init # Replacing 'super()' with 'super' gives: 1027>ruby r2.rb ../r1.rb:18:in `initialize': wrong number of arguments(2 for 0) (ArgumentError) from ./r1.rb:18:in `initialize' from r2.rb:10:in `new' from r2.rb:10 > > Maybe this is important: Nope. Not it. > class A > def initialize > @time = Time.new #here the error happens > end > end > > Maybe does A pass the params to Time which doesn't define a no-arg init? > > Michael > -- Daniel Kelley - San Jose, CA For email, replace the first dot in the domain with an at.