Robert Klemme
5/29/2006 7:19:00 AM
ryanslists@gmail.com wrote:
> Thanks Tim, the attr_* docs did explain well the whole methodname=
> thing. It sounds like I do have to use the relatively baroque syntax,
> which I guess is fine.
>
> It just seems inelegant by ruby standards -- it would be cool if there
> was a method called __attr_write__ or somesuch --
> obj.__attr_write__(methodname, value). I'm also not sure why
> obj.__send__(methodname, value) doesn't just work --- I guess there is
> difference between method arguments and assigned values --
> obj.foo(a,b,c) = value is valid maybe? As you can see I am new to the
> language.
>
> Also, the .__send__ over .send is hugely lame, but whatever Done
> decision apparently And I can keep using for now ;->
>
> Do appreciate your help.
>
> Best regards,
> RT
>
You need to do
obj.send("#{attr_name}=", val)
and not
obj.send(attr_name) = val
Kind regards
robert