From: why the lucky stiff Date: 2003-07-05T00:31:36+09:00 Subject: Re: purpose of replace method Anders Borch (spam@deck.dk) wrote: > > > >I believe he wants #become. > > > > yep, but that's not in Object either. > See [ruby-core:1164]. I guess `become' was added, then disappeared. Cited as being too dangerous. I think it's a possible and valuable feature for Ruby, but some disagree. You can actually get away with doing some of the same tricks with a Delegator. If you check out Delegator and WeakRef classes, you'll see some semblance of pointers. Here's an initial stab at a WeakRef#become, which serves proper in most of my cases. require 'weakref' class WeakRef def become(obj) ID_MAP.delete self.__id__ initialize(obj) self end end Example usage: >> a = [1, 2] >> b = [3, 4] >> c = WeakRef.new a >> puts c.inspect [1, 2] >> c.become b >> puts c.inspect [3, 4] Also see ObjectSpace#_id2ref. _why