William Djaja Tjokroaminata wrote:
> dblack / candle.superlink.net wrote:
> > Yes, if the class var is already initialized.  However (1.6.7):
> 
> >   candle:~$ ruby -ve 'a ||= 3; @a ||= 3; @@a ||= 3'
> >   ruby 1.6.7 (2002-03-01) [i686-linux]
> 
> This is very interesting.  Should Ruby be more consistent in this respect?

That might be a bad idea, since class variables are more "magical" than
both instance variables and local variables.

The inheritance hierarchy level where the class variable is first
defined decides where it is visible. This is not a problem with local
variables nor instance variables. Although it is alot more verbose,
using the "@@a = 1 unless defined? @@a" trick gives you the same
functionality, but is easier to spot while reading, if it causes a bug.

-- 
(\[ Kent Dahl ]/)_    _~_    __[ http://www.stud.ntnu.no/~kentda/ ]___/~
 ))\_student_/((  \__d L b__/  NTNU - graduate engineering - 5. year  )
( \__\_?|?_/__/ ) _)Industrial economics and technological management(
 \____/_?_\____/ (____engineering.discipline_=_Computer::Technology___)