From: Andrea Maschio Date: 2007-08-02T16:27:41+09:00 Subject: Re: Dynamic method call ------=_Part_22173_29741774.1186039665412 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Ok, Gregory, now i understand that i didn't explain very well. The only part in wich the user (let's say a VERY junior programmer) is the scripting interface i provide for him, so he will write if_is_true(a_condition, "do_something(arg1,arg2)") tha internal implementation is my matter, but if you think eval is bad (i probably understand why), the solution with send(:method,arg1,arg2) is probably good, but how can i allow a user to input the method name with his arguments? Anyway, i'm going to try. 2007/8/1, Gregory Brown : > > On 8/1/07, Andrea Maschio wrote: > > the problem is that method_name is a static call, i need to make it > dynamic > > and choosed by the user/programmer, so at least he should type > > eval("method_name(arg1,arg2)") if condition > > > > but my aim was just to encapsulate this in a more comprehensible grammar > > like > > > > if_it_happens_that(is_true, "do_something(arg1,arg2)") > > > > in another language that english it sound more different using english > word > > "like if, then, end, do" > > > > i know it could sound weird, but this was my need, and i solved it with > eval > > (of course the internal logic is far more complex) > > I still don't quite understand the problem you're tring to solve, but > consider using send(:method,arg1,arg2) instead of eval(). You're > begging for a mess using eval() to allow end users to input stuff. > > -- Andrea Maschio http://www.superandrew.it A clever person solves a problem. A wise person avoids it. Einstein ------=_Part_22173_29741774.1186039665412--