-
-
Save ravisun66/e81ffcb28c69642b930387cb551a5efd to your computer and use it in GitHub Desktop.
Ruby meta-programming check
This file contains 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
class Demo | |
D = 10 | |
end | |
d1 = Demo.new | |
d2 = Demo.new | |
def d1.check | |
D | |
end | |
class << d2 | |
def check | |
D | |
end | |
end | |
d1.check ## NameError: uninitialized constant D | |
d2.check ## 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment