From: sur max Date: 2007-02-16T22:40:32+09:00 Subject: Re: class design issues ------=_Part_3230_25716479.1171633226414 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline But i think there is a point to discuss here... as lf1.name is simply an instance method which is(should be) only capable of returning the instance variable "@name" so by defining :name as attr_reader should block everything which is trying to write the instance variable "@name" On 2/16/07, sur max wrote: > > It means even need not to go for lf1.instance_variable_set > > it is pretty working as > > lf1.name.gsub!(/.*/,"") > > lf1.name << "new broken name" > > On 2/16/07, dblack@wobblini.net wrote: > > > > Hi -- > > > > On Fri, 16 Feb 2007, sur max wrote: > > > > > Hi David, > > > > > > Now this should not be available !! > > > > > > lf1.name << "more stuffs" > > > this should generate error !! ... (i agree it is working) > > > > Strings response to "<<", so assuming lf1.name returns a string, > > there's no error of any kind here. > > > > > but is name is an attr_reader then the manipulations with "<<" should > > not be > > > supported, as the case of "=" > > > or it should be ? > > > > It's not really that = is or is not supported; it's all a matter of > > what methods you define. If you define a method that returns a > > string, then you get a string, which is mutable, from that method. > > The notion of an "attribute" is really in the mind of the programmer. > > Objects don't know whether they're attributes or not; they just exist, > > and do what they're told. > > > > > > David > > > > -- > > Q. What is THE Ruby book for Rails developers? > > A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black ) > > (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) > > Q. Where can I get Ruby/Rails on-site training, consulting, coaching? > > A. Ruby Power and Light, LLC ( http://www.rubypal.com) > > > > > > > -- > sur > http://expressica.com -- sur http://expressica.com ------=_Part_3230_25716479.1171633226414--