From: CT Date: 2004-07-25T20:27:56+09:00 Subject: Re: [NUBY] Instance variable accessible from class method? On Sun, 25 Jul 2004 19:57:46 +0900, Alexey Verkhovsky wrote: > Result of executing this code: > > class MyClass > > @instance_variable = "aaa" Here, @instance_variable is an instance variable of the class object MyClass. See: http://www.rubygarden.org/ruby?ClassInstanceVariables Everything is an object in Ruby, even classes. You were probably looking for something like: class MyClass def initialize @instance_variable = "aaa" #this means @instance_variable is an instance variable for #objects of this class end def MyClass::class_method puts @instance_variable end end In which case MyClass.class_method will print 'nil', as expected. HTH - CT > def MyClass::class_method > puts @instance_variable > end > > end > > MyClass.class_method > > is "aaa". > > I expected it to be "undefined variable". > > What is the meaning of instance variable being accessible from a class > method? Which instance holds the value of that variable, if none has > been explicitly created yet? > > Best regards, > Alexey Verkhovsky > >