Bug #3769
closedRemoving Predefined Constants
Description
=begin
The documentation for Module#remove_const states "Predefined classes and singleton objects (such as true) cannot be removed", but I believe the example below illustrates that they can. Is this a documentation or implementation bug?
run@paint:~ → cat /tmp/remove_const.rb
Module.constants.grep(/(?<!Object)$/).tap do |c|
c.each {|_| Object.class_eval{ remove_const } }
p c.select{|| Object.const_defined? _}
end
run@paint:~ → ruby -vw /tmp/remove_const.rb
ruby 1.9.3dev (2010-08-30 trunk 29147) [i686-linux]
[]
=end
Files
Updated by runpaint (Run Paint Run Run) over 13 years ago
- File mod-remove-const.patch mod-remove-const.patch added
=begin
Category changed from core to DOC
Assuming this means the docs are at fault, the attached removes the last sentence "Predefined classes and singleton objects (such as true) cannot be removed." on the basis that my above description proves the first clause wrong, and the latter is implied by the fact that methods such as #constants don't regard true as a constant, either.
=end
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r29519.
Run Paint, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end