On 11/14/05, Mauricio Fernández <mfp / acm.org> wrote:> On Tue, Nov 15, 2005 at 07:16:06AM +0900, Mauricio Fernández wrote:> > On Tue, Nov 15, 2005 at 06:56:59AM +0900, Robert Evans wrote:> > > Hi Ryan,> > >> > > Thanks for your help.> > >> > > I tried that, and it didn't work. Here is my irb transcript trying> > > that. Is there another way to remove a constant? I thought I had seen> > > one in the Pickaxe book, but maybe I was thinking of the module method.> > >> > > irb> > > irb(main):001:0> FOO = "my symbol value"> > > => "my symbol value"> > > irb(main):002:0> remove_const(FOO)> > > NoMethodError: undefined method `remove_const' for main:Object> > >         from (irb):2> > > irb(main):003:0> remove_const(:FOO)>> Sorry, I meant>  Object.send(:remove_const, :FOO)
I may be wrong, but I think using #send to bypass private methodencapsulation is not future-proof. Instead, you might use
  Object.instance_eval{ remove_const :FOO }
This is almost guaranteed to work in the future.
cheers,Mark