Created
March 27, 2009 22:03
-
-
Save pete/86927 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
| # 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