From: Hal Fulton Date: 2004-04-06T06:26:28+09:00 Subject: Re: object.@attribute rolo wrote: > Why cannot we have attribute access of the object from anywhere in the program by sennding a message @attribute > > class Example > def initialize > @number = '1.0' > end > end > > e = Example.new > print e.@number => should print 1.0 That's not how it works. In Ruby, all data members are private by default. They can be accessed *only* through methods. I don't recognize your name offhand. If you are a nuby, you may not be aware of these possibilities for the class: attr_reader :number # Let outside world read this value attr_writer :number # " " " set it attr_accessor :number # " " " read or set it In practice, I've never used attr_writer. It's hard to imagine something useful being write-only and not readable. (Insert Perl wisecrack here.) Hal