On Feb 3, 2009, at 3:39 PM, Jason Shelton wrote:

>
> Hello,
>
> I currently have an array of strings.  Let's say, for example, my  
> array contains the following:
>
>                            ['one', 'two', 'three']
>
> Each element in my array is the name of a function in my program.  I  
> want to call the functions, using the array element.  So for  
> example, lets say that my array is named 'numArray'.  I want to call  
> the function in my program named 'one'.  I am now trying  
> numArray[0].  Is there a way to make the numArray[0] be recognized  
> as 'one' and call the function?  If my question is not clear, I can  
> elaborate.  Thanks in advance for all help.


Convert the string to a symbol and send it to the appropriate object.

   > send( numArray[0].to_sym )
   => NoMethodError: undefined method 'one' for main:Object

   > def one; puts "One!"; end
   => nil

   > send( numArray[0].to_sym )
   One!
   => nil