Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amiel
Last active December 23, 2015 07:39
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 amiel/6602750 to your computer and use it in GitHub Desktop.
Save amiel/6602750 to your computer and use it in GitHub Desktop.
module Foo
class Bar;end
end
module Foo
class Baz
# lookup order: Foo::Baz::Bar, Foo::Bar, Bar
Bar.new # => #<Foo::Bar:...>
end
end
class Foo::Baz
# Note that here it skips lookup for Foo::Bar. This is because
# we are not in the Foo namespace, only in the Foo::Baz namespace
# lookup order: Foo::Baz::Bar, Bar
Bar.new # => NameError: uninitialized constant Foo::Baz::Bar
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment