Hi --

On Mon, 12 Jul 2004, kurk_lord / yahoo.fr wrote:

> Hi all,
> 
> in ruby class variables are private. Who know to do
> for making them accessible to the outsite world. I
> am looking for to do something like in Java :
> 
> Toto.count
> 
> Toto is my class and count is my class variable.

You could do:

  class Toto
    def Toto.count
      @@count
    end
  end

As an Object, a Class is also entitled to have its own instance
variables.  So you also use @count in the above, rather than @@count.
(And actually @count has some advantages, in terms of scope.  It
actually *more* private to the class -- but still can be made visible
through a method, if the class wants it to be.)


David

-- 
David A. Black
dblack / wobblini.net