Tobias Peters wrote: > >> > So it >> > would make sense to instantiate a LogLine with the base data, and then >> > pass that to the subclasses. But when instantiating the subclass, the >> > subclass has to copy over all the data and throw out the copy of the >> > superclass, which seems a little wasteful. > > You want a "become" method: > > d = LogLine.new(...) > old_id = d.id > puts d.class => LogLine > d.become(LogLine_Subclass) > puts d.class => LogLine_Subclass > puts (d.id == old_id) => true Excatly! Although I'd be nervous about doing it in this fashion. Instead, I'd only use it in constructors, as it would scare me to change the type changing during runtime. And I think I'd only do it with the direct superclass. So I'd use it something like this: class LogLine_Subclass < LogLine def initialize(arg) if arg.class == self.class.superclass become(arg) else super(arg) end # do subclass initialization here end end That still seems subtly weird to me, but I think y'all can see where I'm headed. > To my knowledge, ruby does not have this functionality. I'd like to be > proven wrong on this. Maybe its possible to implement this in a C > extension that does some tricks with ruby's object representation? Hmmm... That's a little more than I want to tackle during my first week using Ruby. :-) But if there's a less hairy way to do this, that's swell. Otherwise, I can just copy all the data from the superclass to the subclass. Thanks, William P.S. Thanks again to everybody for putting up with newbie questions like this. If the FAQ maintainer would like any of these questions in the FAQ, just let me know and I'll summarize and rewrite things to be in FAQ form.