Created
April 18, 2013 15:41
-
-
Save rks/5413746 to your computer and use it in GitHub Desktop.
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
class Thing | |
if ENV['DEFINE_NESTED_CLASS'] | |
class SpecificThing | |
def identify | |
'nested' | |
end | |
end | |
end | |
end | |
class SpecificThing < Thing | |
def identify | |
'top-level' | |
end | |
end | |
t = Thing::SpecificThing.new | |
puts t.identify | |
# $ ruby /tmp/things.rb | |
# /tmp/things.rb:17: warning: toplevel constant SpecificThing referenced by Thing::SpecificThing | |
# top-level | |
# | |
# $ DEFINE_NESTED_CLASS=true ruby /tmp/things.rb | |
# nested |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment