From: Stefano Crocco Date: 2008-02-03T21:18:51+09:00 Subject: Re: How to access a method when method-name is in a variable 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