Hi -- On Wed, 11 Oct 2006, Tim Pease wrote: > On 10/10/06, Dipesh Batheja <dipesh_batheja / yahoo.com> 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 I'd steer clear of class variables unless there's some very compelling reason to use them. Classes can have regular attributes: class C def self.x @x end def self.x=(value) @x = value end end I realize Dipesh said "class level", which could mean specifically using class variables, but then again, class variables aren't really class level (they're class/sub[sub[...]]class/instances-level). David -- David A. Black | dblack / wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org