Last active
August 29, 2015 14:16
remove_const
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module A | |
module B | |
module C | |
def self.f() | |
puts "X = #{X}" | |
end | |
end | |
end | |
end | |
a = ::A | |
b = ::A::B | |
c = ::A::B::C | |
X = "::X" | |
c.f | |
A::X = "::A::X" | |
c.f | |
A::B::X = "::A::B::X" | |
c.f | |
a.class_eval do | |
remove_const :B | |
end | |
c.f # => "::A::B::X", why not "::A::X"? | |
b.class_eval do | |
remove_const :X | |
end | |
c.f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment