fork download
  1. class Test
  2. class << self
  3. attr_accessor :foo
  4. end
  5. self.foo = 0
  6.  
  7. def initialize
  8. self.class.foo += 1
  9. end
  10. end
  11.  
  12. 4.times{ Test.new }
  13.  
  14. p Test.foo == 4
Success #stdin #stdout 0s 4716KB
stdin
Standard input is empty
stdout
true