Hi we wanted to access a class varaible from outside of the same class, like class klass @@var1 end we found out we can not use the class variable like this: klass.var1 we have to create a class function like class klass @@var1 def var1 return @@var1 end end If anyone know how to access a class variable directly without passing by a function??? Thanks you very much Saiho The mind is its own place, and in itself. Can make a Heaven of Hell, a Hell of Heaven. http://www.geocities.com/sayoyo/ __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
on 2006-04-25 20:26
on 2006-04-26 00:26
>From picaxe book: " Class variables are private to a class and its instances. If you want to make them accessible to the outside world, you'll need to write an accessor method. This method could be either an instance method or, leading us neatly to the next section, a class method. "
on 2006-04-26 00:52
Saiho sayoyo wrote: > Hi > > we wanted to access a class varaible from outside of > the same class, like > > class klass > @@var1 > end Try cattr_accessor :some_var works just like attr_accessor except for class variables.