From: "Peña, Botp" Date: 2008-08-23T13:05:55+09:00 Subject: Re: remove_const, Kernel.load, and already instantiated objects From: Brent Dillingham [mailto:brentdillingham@gmail.com] # ... # >> puts File.read('foo.rb') # class Foo # def hello # "Hello, world!" # end # end # => nil # >> require 'foo' # => true ok. you used require # # Reload the file using remove_const and Kernel.load # >> Object.send(:remove_const, :Foo) # => Foo # >> Kernel.load('foo.rb') # => true now you use load. let us stick to require... ;) irb(main):001:0> require 'foo.rb' => true irb(main):002:0> f=Foo.new => # irb(main):003:0> f.hello => "hello" ok irb(main):004:0> require 'foo.rb' => false irb(main):005:0> f.hello => "hello" as expected, no change. let's see if we can cheat ;) irb(main):006:0> $LOADED_FEATURES => ["e2mmap.rb", "irb/init.rb", "irb/workspace.rb", "irb/context.rb", "irb/extend-command.rb", "irb/output-method.rb", "irb/notifier.rb", "irb/slex.rb", "irb/ruby-token.rb", "irb/ruby-lex.rb", "readline.so", "irb/input-method.rb", "irb/locale.rb", "irb.rb", "irb/ext/history.rb", "irb/ext/save-history.rb", "foo.rb"] ah irb(main):007:0> $LOADED_FEATURES.delete "foo.rb" => "foo.rb" irb(main):008:0> require 'foo.rb' => true irb(main):009:0> f.hello => "new hello" is that ok? ... caveat, i'm not sure if that is documented/supported. maybe, verify fr matz or nobu.. kind regards -botp