Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. class Foo
  2. @foo_count = 0 <---- instance variable
  3.  
  4. def self.increment_counter <---- class method
  5. @foo_count += 1
  6. end
  7.  
  8. def self.current_count
  9. @foo_count
  10. end
  11. end
  12.  
  13. class Bar < Foo
  14. @foo_count = 100
  15. end
  16.  
  17. Foo.increment_counter <---- how class method can access to instance variable?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement