From: Robert Klemme Date: 2011-01-07T17:26:14+09:00 Subject: Re: Class Initialization? On Thu, Jan 6, 2011 at 10:43 PM, Gary Wright wrote: > > On Jan 6, 2011, at 3:06 PM, Kedar Mhaswade wrote: >> >> And in the process of explaining this, you also indirectly explained one >> question that was lurking in my mind -- are the >> attr_readers/writers/accessors available to class variables -- and as I >> understand it, they are -- by way of your previous class << self >> construct. > > Careful here. The attr* methods are manipulating instance variables and > not class variables. > > instance variables:        private to an object > class instance variables:  instance variables for an object that >                           just happens to be a class > class variables:           nasty, confusing things that have the same name >                           but not at all the same semantics as 'class >                           variables' in other languages > > > I think it is very unfortunate that a lot of introductory Ruby texts choose > to emphasize class variables (@@foo) over plain old instance variables of > a class (@foo for a class object). Completely agree. > If there were one feature I would remove from Ruby (maybe in Ruby 2.0?) it > would be class variables. +2 We could start by flagging usage of class variables with a warning - at least with option -w set. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/