From: lasitha Date: 2009-03-02T23:24:41+09:00 Subject: Re: Delegating class methods On Mon, Mar 2, 2009 at 4:35 PM, abc wrote: > I'm the OP. Thank you all for your replies. Hello OP :) > I'm not a seasoned Ruby programmer, but I think I was totally right in > the idea of using class variables (@@hash). I cannot see why some > people are surprised. I'd be very happy if somebody could shed some > light on the issue, because maybe I'm missing something... There is a school of thought that eigenclass [1] instance variables are generally preferred over @@class_variables. Folks coming to ruby from other languages often miss the distinction but you'll find many exposés on this [2], including in the Pickaxe. I personally like eigenclass variables - they provide all the capability of class variables, fit elegantly into ruby's object model and follow all the rules of instance variables. So i don't ever bother with class vars. It's important to note this is completely orthogonal to the discussion about whether it's appropriate to use any class-level state at all. That has been adequately addressed in this thread already, but it's possible some of the questioning about class variables may actually have revolved around whether to use eigenclass variables instead. Solidarity, lasitha. [1] a.k.a singleton class, metaclass, etc. [2] http://tinyurl.com/3xeef2 http://tinyurl.com/2rnzrf http://tinyurl.com/2thspb http://tinyurl.com/2p3wc6