Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kwstannard
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwstannard/c0f722976ba023cc5755 to your computer and use it in GitHub Desktop.
Save kwstannard/c0f722976ba023cc5755 to your computer and use it in GitHub Desktop.
Ruby inconsistency in constant lookup
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