Last active
August 29, 2015 14:12
-
-
Save kwstannard/c0f722976ba023cc5755 to your computer and use it in GitHub Desktop.
Ruby inconsistency in constant lookup
This file contains 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 | |
end | |
end | |
module C | |
include A | |
puts B.inspect # => A::B | |
class D | |
puts B.inspect rescue puts 'failed' # => failed | |
end | |
# Setting B inside C allows it to be found as expected. | |
B = B | |
class E | |
puts B.inspect # => A::B | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment