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)