Skip to content

Instantly share code, notes, and snippets.

@kalorz
Last active September 15, 2017 10:34
Show Gist options
  • Save kalorz/7d6130a662ecc18a832408f546bf5583 to your computer and use it in GitHub Desktop.
Save kalorz/7d6130a662ecc18a832408f546bf5583 to your computer and use it in GitHub Desktop.
Ruby Gotchas: Lexical Scope vs Inheritance
MY_SCOPE = 'Global'
module Foo
MY_SCOPE = 'Foo Module'
class Bar
def scope1
puts MY_SCOPE
end
end
end
class Foo::Bar
def scope2
puts MY_SCOPE
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment