From: Sharon Phillips Date: 2007-08-01T15:51:30+09:00 Subject: Re: Dynamic method call > I'm trying, for the purpose of making something similar to a > grammar, to do > this > > if_a_condition_is_true(condition, "method_name(arg1, arg2)") > > where > > def method_name(arg1, arg2) > #do something > end > > i've tried many way to implement > > def if_condition_is_true(condition , action) > #such as > eval(action) > #or > call self.method(action) > > end > > but noone worked, i've trying googling a bit but no chances. Have > you got an > idea on how to call dynamically a method, with his arguments? Hi, I'm not sure of why you need to implement it like this, but that's up to you. This works for me: def if_condition_is_true(condition , action) eval(action) if condition end def method_name(arg1, arg2) puts arg1+ arg2 end if_condition_is_true(true, "method_name(2, 3)") Cheers, Dave