From: Dick Davies Date: 2004-03-30T04:09:02+09:00 Subject: Re: classes dynamic loading * saiph [0335 19:35]: > > hi list, > i ve been learning ruby from 2 days. > i found it at impact a faboulous language. > > i would implement something like this: > > in the main file > class Test > def msg > puts 'to overload' > end > end > > t1 = Test.new > t2 = Test.new > > class < load 'myclass' > end > > class < load 'myclass2' > end > > then in myclassN > def msg > puts 'overloadedN' > end > > how can i do that in your opinion? > tnx. Ooh! Ooh! I know this one! 0rasputin@lb:rasputin$ ruby dyn.rb before overload to overload to overload after overload: overload1 overload2 0rasputin@lb:rasputin$ expand -t2 dyn.rb class Test def msg puts 'to overload' end end t1 = Test.new t2 = Test.new puts 'before overload' t1.msg ; t2.msg class << t1 def msg puts 'overload1' end end class << t2 def msg puts 'overload2' end end puts 'after overload:' t1.msg ; t2.msg 0rasputin@lb:rasputin$ -- Fifth Law of Procrastination: Procrastination avoids boredom; one never has the feeling that there is nothing important to do. Rasputin :: Jack of All Trades - Master of Nuns