Stefano Crocco
2/3/2008 12:19:00 PM
Alle Sunday 03 February 2008, Luca Scaljery ha scritto:
> An other question, is it possible to assign a value to an attribute this
> way
>
> For example, this doesn't work
>
> my_object.send(my_var) = 2000
>
> thnx in advance
> LuCa
>
> Stefano Crocco wrote:
> > Alle Sunday 27 January 2008, Luca Scaljery ha scritto:
> >> doesn't work
> >>
> >> Any suggestion
> >>
> >> thnx a lot
> >> LuCa
> >
> > my_object.send( my_var)
> >
> > Stefano
Yes, you can. You must understand that, when you do:
my_object.my_var= 2000
you're actually calling the my_var= method of my_object with argument 2000.
Therefore, to do this with send, you need to do:
my_object.send(:my_var=, 2000)
Stefano