From: Raveendran .P on
Raveendran .P wrote:
> Hi All,
>
> def one
> puts "hi"
> end
>
> Once i call one --> i can able to get a output.
>
>
> QUESTION:
>
> I have a array method_list=["one"]
>
> How can I convert "one" to method ?
Tried and Got Solution


Solution:

eval("one")

Thanks
--
Posted via http://www.ruby-forum.com/.

From: Jesús Gabriel y Galán on
On Mon, Jun 21, 2010 at 1:00 PM, Raveendran .P <jazzezravi(a)gmail.com> wrote:
> Raveendran .P wrote:
>> Hi All,
>>
>> def one
>>  puts "hi"
>> end
>>
>> Once i call one --> i can able to get a output.
>>
>>
>> QUESTION:
>>
>> I have a array method_list=["one"]
>>
>> How can I convert "one" to method ?
> Tried and Got Solution
>
>
> Solution:
>
> eval("one")

I'd rather use send:

irb(main):001:0> def one
irb(main):002:1> "hi"
irb(main):003:1> end
=> nil
irb(main):004:0> list = %w{one}
=> ["one"]
irb(main):005:0> send(list.first)
=> "hi"

Jesus.