On Fri, 22 Aug 2003 12:32:12 +0900
"Gavin Sinclair" <gsinclair / soyabean.com.au> wrote:

<snip>
> > I'd like to know if you are a designer, how would you design class
> > variables in Ruby?  And how useful they are in daily usage?
> > I'm just curious.
> >
> > 							matz.
> 
> Interestingly, I find I never actually use class variables.  I don't know
> why or why not.  I did in Java, but perhaps Ruby has simpler ways of
> achieving the same things?

I do regularly.  In many classes, I have a SQLIndex which helps me query
values across thousands or more objects quickly.  It works like this:

    class MyClass
      @_index = SQLIndex.new(...)
    end

I also have MyClass._index defined.  There was confusion on my part
until I realized that @instance variables in a class were analogous to
"class" or "static" members in Those Other Languages, whereas @@class
variables were different.

Basically, in Ruby, you _do_ have what C++/Java would call a "static
class member", and you also have something else---@@class variables.
It's mostly the term here that's confusing, I think.

-- 
Ryan Pavlik <rpav / users.sf.net>

"Let super-dimensional physics take its course!" - 8BT