From: Robert Klemme Date: 2011-01-06T17:10:40+09:00 Subject: Re: Class Initialization? 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. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/