From: Robert Klemme Date: 2009-10-24T00:20:09+09:00 Subject: Re: Setting attribute via send in Ruby 1.8.6 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. > > Example: > > class A > attr_reader :foo > attr_writer :foo > end > > a = A.new > a.send("foo", "newval") > > > 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. ... :-) You need to use the _setter_ method with #send - which happens to be called "foo=" in your case. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/