-
-
Save anonymous/3844245526602050cfa0 to your computer and use it in GitHub Desktop.
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 Foo | |
@foo_count = 0 <---- instance variable | |
def self.increment_counter <---- class method | |
@foo_count += 1 | |
end | |
def self.current_count | |
@foo_count | |
end | |
end | |
class Bar < Foo | |
@foo_count = 100 | |
end | |
Foo.increment_counter <---- how class method can access to instance variable? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment