Skip to content

Instantly share code, notes, and snippets.

@nagachika
Created July 7, 2014 14:50
Show Gist options
  • Save nagachika/24319b5329e67ff9ad9a to your computer and use it in GitHub Desktop.
Save nagachika/24319b5329e67ff9ad9a to your computer and use it in GitHub Desktop.
ruby constant lookup
module A
class << self
def foo
p B
end
end
B = "A::B"
end
B = "Toplevel B"
A.foo # => "A::B"
module A
B = "A::B"
end
def A.foo
p B
end
B = "Toplevel B"
A.foo # => "Toplevel B"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment