From: Duong Quang Ha Date: 2012-05-25T12:42:45+09:00 Subject: Re: Modify an attribute in a method? --047d7b10ce693acd5304c0d42962 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, On Fri, May 25, 2012 at 10:14 AM, Robinson Risquez wr= ote: > > k=3D0 > > while (k<10) do > > puts val.attribute+=3D1 > > k+=3D1 > > end > > > Certainly can be done in many ways, but what I want to do is spend just > an attribute as a parameter to a method of the form: object.attribute, > then you can modify this attribute in the method, as follows: > > def adder (attribute) > attribute + =3D 1 > end > > That's what I do, but can not find the way. > > I'm sorry, just to make the problem more clear. You mean that you want to modify arbitrary attribute(s) from outside object, dont' you? Can you give me some examples with object's state before and after you call this method. Sincerely, --=20 Duong Quang Ha (H=C3=A0 Quang D=C6=B0=C6=A1ng in Vietnamese) blog.haqduong.com --047d7b10ce693acd5304c0d42962 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi,

On Fri, May 25, 2012 at 10:14 AM, Rob= inson Risquez <lists@ruby-forum.com> wrote:
> k=3D0
> while (k<10) do
> =C2=A0 puts val.attribute+=3D1
> =C2=A0 k+=3D1
> end


Certainly can be done in many ways, but what I want to do is spend ju= st
an attribute as a parameter to a method of the form: object.attribute,
then you can modify this attribute in the method, as follows:

=C2=A0def adder (attribute)
=C2=A0 attribute + =3D 1
=C2=A0end

=C2=A0That's what I do, but can not find the way.

=


I'm sorry, just to make the problem = more clear.

You mean that you want to modify arbit= rary attribute(s) from outside object, dont' you?

Can you give me some examples with object's state b= efore and after you call this method.


Sincerely,

--
Duong Quang Ha (H=C3=A0 Quang D=C6= =B0=C6=A1ng in Vietnamese)
blog.haqduong.com

--047d7b10ce693acd5304c0d42962--