From: Charles Calvert Date: 2009-10-24T01:40:07+09:00 Subject: Re: Setting attribute via send in Ruby 1.8.6 On Fri, 23 Oct 2009 17:18:22 +0200, Robert Klemme wrote in <7kdvpuF37n3jvU1@mid.individual.net>: >On 10/23/2009 05:10 PM, Charles Calvert wrote: >> Using Ruby 1.8.6. >> >> I've run into an instance in which I'd like to set attributes of an >> instance using the send method. I've looked around, but found >> nothing, most likely because I'm using the wrong search terms. [snip example] >> I get the following error: "wrong number of arguments (1 for 0) >> (ArgumentError)" >> >> Am I correct in thinking that this is possible, and that I'm just >> going about it the wrong way? > >Yes. > >... The suspense almost killed me! >:-) > >You need to use the _setter_ method with #send - which happens to be >called "foo=" in your case. Ah, now the lightbulb goes off. I should have remembered the convention of having the setter have an equals sign as part of the name. I'm too used to languages that determine which accessor is used based on which side of the assignment it appears rather than actually using a method name to syntactically simulate assignment. Thanks for the help. -- Charles Calvert | Web-site Design/Development Celtic Wolf, Inc. | Software Design/Development http://www.celticwolf.com/ | Data Conversion (703) 580-0210 | Project Management