"MikkelFJ" wrote .... > Ruby is very dynamically type so you can only stretch the analogy so far. I am worried that your analogy might be rather misleading. The scoping rules for so called ``nested'' classes or modules are radically different (they are only an illusion based on coding convention and strictly speaking don't exist at all ) from the so called static scoping rules of C++'s or Java's inner classes ... > > > class << anon > > def my_name > > puts @my_name > > end > > end > > What you do in the above is to access the Singleton class of the > instantiated object, which is different. To you mean different to accessing the Singleton class class << A def an_other_meth end end of the non anonymous Class object A in order to define a (supposably static) class method? These two construct neither look nor work any differently ... > > > > > anon.new.inst_meth # an_inst > > anon.my_name # anon > > > A.const # anon's_const > > This is the static class, but it is just the same as before. After all you > did earlier declare My point was that the ``defining scope'' the class method ``const" of the ``static'' Class object "A" was a local Class object ``anon'' - b.t.w. other A class methods might have a different "defining scope". > > > class A; end > > The need to do this actually stresses the point that it has a static nature. There was no need to do this. I might as well have written --- anon = Class.new anon2 = Class.new anon.class_eval <<-ENd @my_name = "anon" def inst_meth puts "an inst" end Const = "anon's_const" def anon2.const puts Const end ENd class << anon def my_name puts @my_name end end anon.new.inst_meth # an_inst anon.my_name # anon anon2.const # anon's_const # just for the heck of it, deanonymize anon ... p anon # #<Class:0x277b6f8> A = anon p anon # A A.my_name # anon --- /Christoph