--------------AA250E39030A1F17F9CC40D6 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Yukihiro Matsumoto wrote: > Hi, > > In message "[ruby-talk:15828] subclassing Date" > on 01/05/28, Michael Husmann <Michael.Husmann / teleatlas.com> writes: > > |Using ruby 1.6.0 and trying to subclass the Date class like > |this: > | > |class My_date < Date > | def initialize(st) > | l plit(".") > | y, m, d .collect{|s| s.to_i} > | super(y,m,d) > | end > |end > | > |ruby throws the following error messages when invoking: > |d y_date.new("2001.5.28") > | > |/usr/local/lib/ruby/1.6/date.rb:33:in `civil_to_jd': > |undefined method `-' for "2001.5.28":String (NameError) > |/usr/local/lib/ruby/1.6/date.rb:139:in `exist3?' > |/usr/local/lib/ruby/1.6/date.rb:147:in `new3' > > You're calling `super("2001.5.28",...)'. I think there's something > wrong before calling super. Try: > > class My_date < Date > def initialize(st) > l t.split(".") # note "st." > y, m, d .collect{|s| s.to_i} > super(y,m,d) > end > end > > matz. Hi Matz, yes I have forgotten the st before split. But the problem still exists after changing the code Michael -- Michael Husmann p.A. Tele Atlas Deutschland GmbH, Am neuen Horizont 1, 31177 Harsum PHONE: +(49) 5127 408-487, FAX: +(49) 5127 408-481 e-mail: Michael.Husmann / teleatlas.com --------------AA250E39030A1F17F9CC40D6 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> Yukihiro Matsumoto wrote: <blockquote TYPEE>Hi, <p>In message "[ruby-talk:15828] subclassing Date" <br> on 01/05/28, Michael Husmann <Michael.Husmann / teleatlas.com> writes: <p>|Using ruby 1.6.0 and trying to subclass the Date class like <br>|this: <br>| <br>|class My_date < Date <br>| def initialize(st) <br>| l plit(".") <br>| y, m, d .collect{|s| s.to_i} <br>| super(y,m,d) <br>| end <br>|end <br>| <br>|ruby throws the following error messages when invoking: <br>|d y_date.new("2001.5.28") <br>| <br>|/usr/local/lib/ruby/1.6/date.rb:33:in `civil_to_jd': <br>|undefined method `-' for "2001.5.28":String (NameError) <br>|/usr/local/lib/ruby/1.6/date.rb:139:in `exist3?' <br>|/usr/local/lib/ruby/1.6/date.rb:147:in `new3' <p>You're calling `super("2001.5.28",...)'. I think there's something <br>wrong before calling super. Try: <p> class My_date < Date <br> def initialize(st) <br> l t.split(".") # note "st." <br> y, m, d .collect{|s| s.to_i} <br> super(y,m,d) <br> end <br> end <p> matz.</blockquote> Hi Matz, <p>yes I have forgotten the st before split. But the problem still exists after changing the code <p>Michael <pre>-- Michael Husmann p.A. Tele Atlas Deutschland GmbH, Am neuen Horizont 1, 31177 Harsum PHONE: +(49) 5127 408-487, FAX: +(49) 5127 408-481 e-mail: Michael.Husmann / teleatlas.com</pre> </html> --------------AA250E39030A1F17F9CC40D6--