Skip to content

Instantly share code, notes, and snippets.

@hoffm
Last active August 12, 2017 00:55
Show Gist options
  • Save hoffm/199236fe54fea9423ff86a16591d980e to your computer and use it in GitHub Desktop.
Save hoffm/199236fe54fea9423ff86a16591d980e to your computer and use it in GitHub Desktop.
class MyClass
def foo_via_method
p "Superclass Chain: #{self.class.ancestors}"
p "Lexical Scope Chain: #{Module.nesting}"
foo_method
end
def foo_via_constant
p "Superclass Chain: #{self.class.ancestors}"
p "Lexical Scope Chain: #{Module.nesting}"
FOO_CONSTANT
end
end
class SubClass < MyClass
FOO_CONSTANT = "foo"
def foo_method
FOO_CONSTANT
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment