From: Tim Pease Date: 2006-10-11T06:24:00+09:00 Subject: Re: Newbie problem of Class attributes On 10/10/06, Dipesh Batheja wrote: > I am trying to create a class level attribute which can read and write. > I am doing something like this: > > def self.selected_client > -- my code -- > end > > def self.selected_client=(value) > -- my code -- > end > > but its seems that the Ruby interpreter is not liking this. Can someone > tell me how to create class level attributes that can read and write. > > -- > Posted via http://www.ruby-forum.com/. > > class A def self.var() @@var end defl self.var=(v) @@var = v end end A.var = 1 A.var If you try to access a class variable before it is set, the interpreter will throw a NameError at you. Blessings, TwP