From: Greg Willits Date: 2010-10-31T04:27:42+09:00 Subject: Re: Dynamically reference instance vars Appreciate the effort, but the point has been lost. Don't focus on the hash or mass assignment, that was just a device to create an example. The question is whether there's a shorter way to do this: my_object.send(:instance_variable_set, "@#{iname}", ivalue) In another language I used, I could simply do the equivalent of myobject.iname = ivalue that's because the syntax was like this #myobject->#iname = ivalue Where # denotes a local var, so it was obvious to the parser that #iname was not a method name, whereas with Ruby it's not obvious. I was hoping in Ruby that at least this was possible: myobject.send(iname) = ivalue --or-- myobject.send(iname, ivalue) but that doesn't work. I could maybe force it to work by manually creating setter methods, but that's not an elegant solution either, I'd rather have the occassional use of instance_variable_set than craft setters. Anyway, not a biggie, just a curiosity. -- Posted via http://www.ruby-forum.com/.