From: matz@... (Yukihiro Matsumoto) Date: 2003-02-02T00:54:52+09:00 Subject: Re: Coercion of variables Hi, In message "Coercion of variables" on 03/02/02, Brian Candler writes: |However, suppose I have an existing class hierarchy: Bar is a subclass of |Foo. I want to convert obj from an instance of Foo into an instance of the |subclass Bar. | |Is that possible, without creating a whole new Bar object? In general, No. |(Practical example: I have defined a subclass of the TCPSocket object. |TCPServer#accept returns an object of class TCPSocket. I want to convert |this object into my own subclass) How about extending the socket with your module. See Object#extend. s = ss.accept s.extend YourSocketExtensionModule ... matz.