Skip to content

Instantly share code, notes, and snippets.

@pete
Created March 27, 2009 22:03
Show Gist options
  • Save pete/86927 to your computer and use it in GitHub Desktop.
Save pete/86927 to your computer and use it in GitHub Desktop.
# Ruby's awesome constant-resolution rules.
module X
A = 5
end
module X
class Y
def z
A
end
end
end
puts X::Y.new.z
class X::B
def z
A
end
end
module X
class B
def omega
A
end
end
end
puts X::B.new.omega
puts X::B.new.z # oops, exception raised, can't find X::B::A!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment