From: Magicloud Magiclouds Date: 2007-07-17T16:31:09+09:00 Subject: Re: What is the fastest way to convert a object? Robert Klemme wrote: > 2007/7/17, Ryan Davis : >> >> On Jul 16, 2007, at 22:56 , Magicloud Magiclouds wrote: >> >> > Class Test >> > def methodA >> > puts(@var1) >> > end >> > def initialize >> > @var1 = 0 >> > end >> > end >> > >> > obj = Object.new >> > obj.instance_variable_set(:@var1, 2) >> > >> > >> > # Now I want obj to be Test's instance, so I can >> > obj.methodA >> > # How to do this quickly? >> >> You don't. Ruby is strongly typed, which means that things don't just >> "morph" into other types of things automatically or manually. >> Specifically, you can't (without voodoo) set an instance's class. > > Adding to that: MM, what problem are you trying to solve? > > robert > > I am using DRb, and I have many data models need to be generated on server and sent to client. So I think a smaller object would be better. Right?