Skip to content

Instantly share code, notes, and snippets.

@ravisun66
Created September 8, 2016 06:15
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 ravisun66/e81ffcb28c69642b930387cb551a5efd to your computer and use it in GitHub Desktop.
Save ravisun66/e81ffcb28c69642b930387cb551a5efd to your computer and use it in GitHub Desktop.
Ruby meta-programming check
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