From: Lionel Thiry Date: 2005-03-15T23:00:07+09:00 Subject: Re: [newby] class variables and class instance variable? Hello again! I've refactored a bit the code of Wolfgang. Now, it do a lot of reuse through inheretance. I'm really curious to know what this refactored code would give under ruby 1.9.0. Would you mind to test it for me, please? Here it is: class Animal @@born = 0 def initialize @@born += 1 self.class.anew end def self.anew puts "a new animal" end def self.born @@born end end class Dog>>>>>"W" == Wolfgang N�dasi-Donner writes: > > >>>>>Output >>> > > W> 0 cats, 0 dogs, 0 animals > W> a new dog > W> a new dog > W> 2 cats, 2 dogs, 2 animals > W> a new cat > W> a new cat > W> a new cat > W> 5 cats, 5 dogs, 5 animals > >>>>>End of Example >>> > > > With this version of ruby > > uln% ruby -v > ruby 1.9.0 (2005-03-14) [x86_64-linux] > uln% > > The result is > > 0 cats, 0 dogs, 0 animals > a new dog > a new dog > 0 cats, 2 dogs, 0 animals > a new cat > a new cat > a new cat > 3 cats, 2 dogs, 0 animals > >