On 10/20/05, Florian Weber <csshsh / gmail.com> wrote:
> Hi!
>
> Is there a way to remove a class for good from the ObjectSpace? I
> would like to redefine a class entirely without any 'leftovers' of the
> previous definition.

Here is something to think about:

class Module
  def flush(klass)
    remove_const(klass.name.intern)
  end
end

class Foo
end

f = Foo.new
p f

Object.flush(Foo)

p Object.const_defined?(:Foo)
f2 = Foo.new # Causes exception
__END__

The object referred to by variable f will remain in the object space
until you set f to nil and start the GC (or let it run on its own.)

Ryan