From: Alex Stahl Date: 2010-07-12T07:50:17+09:00 Subject: Re: How to pass a hash as a param to a method called through eval? Thanks again, yermej's suggestion actually worked out. I've now got send doing exactly what I wanted to accomplish. Going into my thinking on this problem, I knew I wanted dynamic execution, and being relatively new to ruby, thought that eval would be the right tool. Wasn't aware of send. Great thing is it caused me to look up the Object and see all the cool things it can do for me. So my original question probably should have been, "is eval even the right tool for this?". Of course, that's not always obvious considering there's always more than one way to do something in ruby. On Sun, 2010-07-11 at 16:58 -0500, Ammar Ali wrote: > On Mon, Jul 12, 2010 at 12:41 AM, Alex Stahl wrote: > > > Thanks. You're actually the second response to suggest doing it that > > way (w/ eval). But it doesn't work for me. > > > > Though, the first respondent is using 1.9.1, and I've got 1.8.7 at the > > moment. Are you by chance also on 1.9.1? > > > On 1.8.7 use yermej's suggestion, without the interpolation, if you choose > to stick with eval despite the excellent suggestions to use send instead: > > eval("#{call['action']}(call['params'])") > > Cheers, > Ammar