From: "Arno J." Date: 2007-08-17T18:42:22+09:00 Subject: Re: Does singleton variables have any meaning ? unknown wrote: > self is # (the singleton class of A), so @singleton_variable > belongs to #. It has no connection to A. Ok, that's what I guessed > # is the singleton class (sometimes called the "metaclass") > of A. It's a separate object; it has its own instance variables, and > doesn't share them with A. > > As for the terminology; here: > @var is an instance variable, and self is a class. So we can call it > an instance variable or a class instance variable. I don't think it's > a good idea to introduce yet another term (singleton variable) for it; > it just gets too confusing. I'm sorry but I still don't get it (maybe I'm a little bit nit_picking also) class A @first_instance_var # self = A def meth @second_instance_var # self = # end class << self @thir_instance_var # self = # end end All three variables are instance variables (just because of the @, as far as I know). BUT, for what I've read on the web / in books first_... would be called a "class instance variable" second_... would be called an "instance variable" third_... would not be called (I never met any), or would be called a "class instance variable" according to you, although self is not a class but a singleton class. I agree that since a singleton class is some sort of class, it can be called a "class instance variable". But my question are "how do I access it ?" and "Is it any usefull" (I understand why first and second can be used, but not third). > You could get indirect access to it if the object that owns it creates > wrapper methods for it. But if you put @my_variable where your "This" > comment is, it will be a completely different @my_variable. I don't want to put @my_variable here, I want to use the wrapper method you're talking about, but I don't know how to build it :) > David Thank you for your time Arno -- Posted via http://www.ruby-forum.com/.