From: Yuki Sonoda Date: 2010-10-15T17:16:58+09:00 Subject: [ruby-core:32797] [Ruby 1.9-Bug#3949][Open] Can predefined classes be removed? Bug #3949: Can predefined classes be removed? http://redmine.ruby-lang.org/issues/show/3949 Author: Yuki Sonoda Status: Open, Priority: Normal Assigned to: Yukihiro Matsumoto, Category: core ruby -v: ruby 1.6.8 (2005-09-21) [i386-darwin9.1.0] According to rdoc, Module#remove_const cannot remove predefined classes: > Predefined classes and singleton objects (such as true) cannot be > removed. But actually we can remove them. $ ruby-1.8.0 -ve 'Object.send(:remove_const, :String); p String' ruby 1.8.0 (2003-08-04) [i686-darwin] -e:1: uninitialized constant String (NameError) $ ruby-1.8.1 -ve 'Object.send(:remove_const, :String); p String' ruby 1.8.1 (2003-12-25) [i686-darwin] -e:1: uninitialized constant String (NameError) ... $ ruby-1.9.1 -ve 'Object.send(:remove_const, :String); p String' ruby 1.9.1p427 (2010-05-23 revision 27982) [i386-darwin9.8.0] -e:1:in `
': uninitialized constant String (NameError) $ ruby-1.9.2 -ve 'Object.send(:remove_const, :String); p String' ruby 1.9.2p6 (2010-08-18 revision 29252) [i386-darwin9.8.0] -e:1:in `
': uninitialized constant Object::String (NameError) The rdoc seems to be describing Ruby 1.6: ruby-1.6 -ve 'Object.send(:remove_const, :String); p String' $ ruby 1.6.8 (2005-09-21) [i386-darwin9.1.0] -e:1:in `remove_const': cannot remove Object::String (NameError) from -e:1:in `send' from -e:1 This limitation is intended? or is the rdoc wrong? I think we should be able to remove any class on our own risk. ---------------------------------------- http://redmine.ruby-lang.org