"Bill Clagett" <bill / 32768.com> wrote in .... > It's a class instance variable. > > http://www.rubycentral.com/faq/rubyfaq-8.html#ss8.3 > > bill Hm quoting from the faq (hope nobody minds) > There is no way to access class instance variables from instance methods. which is true (guess I am in a picky mood) if you ignore Class instance methods ---- class Foo @a = 123 # (1) def foo p @a # (2) ... nil not 123 end end class Class def foo p @foo end end Foo.foo # => 123 ---- /Christoph > > ----- Original Message ----- > From: "Stefan Mueller" <flcl / gmx.net> > To: "ruby-talk ML" <ruby-talk / ruby-lang.org> > Sent: Saturday, March 09, 2002 2:44 PM > Subject: Funny Instance Variable? > > > > Hello > > > > while fumbling around with ruby, I stumbled onto the following code. > > I know, this does not look usefull at all, and it should have class vars, > > and not instance vars. > > > > I just wonder, what am I accessing there? Some sort of funny class > > variable, that no instance can access? > > > > > > --begin code > > > > class Foo > > > > def Foo.bar=(bar) > > @bar = bar > > end > > > > def Foo.bar > > @bar > > end > > > > end > > > > > > Foo.bar='whatami?' > > puts Foo.bar #=> "whatami?" > > > > --end code > > >