From: Kedar Mhaswade Date: 2011-01-07T04:43:06+09:00 Subject: Re: Class Initialization? Robert Klemme wrote in post #972742: > On Wed, Jan 5, 2011 at 6:18 PM, Kedar Mhaswade > wrote: > >> It was not clear if the "class body" will be executed at most once. >> That's now clear. > > Good! > >> I like this better than Java's static initializer! >> >> Robert -- but isn't @@x a class variable and @x an instance variable? >> Maybe I am confused a bit. I want this "table" I am initializing to be >> available from the class, without having to create any instances of it. > > Short answer: classes can have instance variables as well. Long > answer (please see Andrew's reply). Variables with @@ are really a > hybrid which is directly readable from the class and instance. But > there are some subtle issues with order in which they are created and > so I always recommend to not use them. You'll find plenty of > discussions of this in the archives. > Perhaps these are the Ruby Pro techniques. I think I have to read more and experiment more to understand them better. Thank you. -- Posted via http://www.ruby-forum.com/.