From: "David A. Black" Date: 2004-11-30T07:49:46+09:00 Subject: Re: Friend class/inner class Hi -- On Tue, 30 Nov 2004, Dan Janowski wrote: > What I am looking for is very similar to a clone. However, instead of > the instance variables referring to the same objects, the variables use > the same reference storage. This way, 'b' which is a friend of 'a' can > change a value of a shared variable and 'a' has the same change. 'b' > can be extended via singleton methods that do not change the 'a' > instance definition. > > I can get close with clone as long as I read-only or change! the shared > instances, but the replacement of a reference in one has no effect on > the other. > > I know I can use instance_eval, but I was hoping for something like > 'clone' in its directness. > > Is there any consideration of this? Is it possible to do with Ruby's > internal constructs? I think that an anonymous subclass is created when > singleton methods are added, but can one instance be directly related > to another instance with the base instance providing its variables as > well? I'm tempted to say: b = a but that probably isn't exactly what you're looking for :-) I'm not quite getting it, though. Can you give an example of what some code would look like that did what you're describing? David -- David A. Black dblack@wobblini.net