From: uncutstone wu Date: 2006-05-21T13:47:26+09:00 Subject: Re: Class variables and class instance variables in Pickaxe James Britt wrote: > A class is also an object; it's an instance of Class. Since it is an > object it may have its own instance variables. Class variables are > available to the class and to instances of that class; class instance > variables are only visible to the class itself (not to instances of that > class). (Yeah, it can be confusing at first.) > > > class Foo > @@cls_var = 123 > @cls_instvar = 'abc' > > def test > p @@cls_var > p @cls_instvar > > end > > def self.test > p @@cls_var > p @cls_instvar > end > end > > > puts( "Foo is a #{Foo.class}") > > f = Foo.new > f.test > Foo.test Very thanks, it's quite clear now. uncutstone -- Posted via http://www.ruby-forum.com/.