From: "Florian G. Pflug" Date: 2001-05-02T01:28:38+09:00 Subject: [ruby-talk:14500] Re: Overloading Constructors. On Tue, May 01, 2001 at 03:44:55PM +0900, Yukihiro Matsumoto wrote: > |If the c-extension does not call initialize from their "new" method, would > |it be possible to overcome this without changing the extension by > |overloading the "new" method in my derived class instead of overloading the > |"initialize" method? > > Invoke "initialize" implicitly. > Here's an example: > > require "mysql.o" > class DbConnection < Mysql > def DbConnection.new(*args) > conn = super(*args) > conn.initialize(*args) > return conn > end > def initialize(host, db, user, pass) > print "In Constructor\n" > end > end > con = DbConnection.new("localhost","rubytest","root", "") Hi This works, thank you! But it has to be just "initialize" instead of "conn.initialize" - otherwise ruby complaing about calling an private function unsing an expicit receiver. greetings, Florian Pflug