Skip to content

Instantly share code, notes, and snippets.

@rks
Created April 18, 2013 15:41
Show Gist options
  • Save rks/5413746 to your computer and use it in GitHub Desktop.
Save rks/5413746 to your computer and use it in GitHub Desktop.
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