Simon Strandgaard
3/29/2005 6:17:00 AM
On Tue, 29 Mar 2005 13:40:35 +0900, Glenn Parker
<glenn.parker@comcast.net> wrote:
> Adelle Hartley wrote:
> > Hi all,
> >
> > Being able to create constants at run-time using Object.const_set is neat
> > and all, but is there a way of un-setting them?
>
> It is actually Module.const_set, and there is also Module.remove_const,
> but that method is private. You may need to use send to invoke it.
something like this:
irb(main):003:0> Object.const_set(:C, 42)
=> 42
irb(main):004:0> Object.send(:remove_const,:C) if Object.const_defined?(:C)
=> 42
irb(main):005:0> C
NameError: uninitialized constant C
from (irb):5
irb(main):006:0>
--
Simon Strandgaard