From: Brad Wilson Date: 2005-07-26T02:50:32+09:00 Subject: Re: An array updatable? ------=_Part_1909_22907169.1122313829877 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline attr_reader means you can get a reference to the cars collection, to which= =20 then you are adding items. attr_reader doesn't imply that the thing it's=20 returning will be treated as read only. That it means is that the user is= =20 not allowed to replace the collection itself. On 7/25/05, EdUarDo wrote: >=20 > Hi again, >=20 > I have this class: >=20 > class A > attr_reader :name, :cars > attr_writer :name >=20 > def initialize(name) > @name =3D name > @cars =3D Array.new() > end > end >=20 > a =3D A.new("xxxx") > a.cars << "vectra" << "megane" > puts a >=20 > output: >=20 > vectra > megane >=20 > Why can I access cars and modify it if I have not declared it how > attr_writer. Must I simply declare it private? >=20 >=20 --=20 Brad Wilson http://www.dotnetdevs.com/ http://www.agileprogrammer.com/dotnetguy/ Peter: "Oh my god, Brian, there's a message in my Alphabits. It says,=20 'Oooooo.' " Brian: "Peter, those are Cheerios." - Family Guy ------=_Part_1909_22907169.1122313829877--