Proposed RCR: Object#replace

I didn't actually want instance variable duplication. All I wanted was
the same bit of memory reused.

- Dan

···

-----Original Message-----
From: David A. Black [mailto:dblack@wobblini.net]
Sent: Wednesday, November 16, 2005 12:32 PM
To: ruby-talk ML
Subject: Re: Proposed RCR: Object#replace

Hi --

On Thu, 17 Nov 2005, Trans wrote:

>> i see where you are coming from, but wouldn't this more
accurately be
>> called something like Object#refer since all instance vars
will then
>> be shared?
>
> class Object
> def replace(other)
> other.instance_variables.each do |name|
> o = other.instance_variable_get(name)
> if o.respond_to? :clone
> instance_variable_set(name, o.clone)
> end
> end
> end
> end

How does instance variable duplication qualify as the general
meaning of "replace"? It's not even part of the existing
replace methods.