Hi there,
I'm looking to put a method in an array, to be called at a later time.
In C, this is possible using pointers (through some rigamarole and
typedefs, it would look like { funct }). Is there any way this can
similarly be acheived in Ruby?
What the end goal is to be able to call the method using 'arr[index]
args'. The purpose of this is that I'm working on a server that might
receive one of hundreds of commands from the client side, and this:
commands = [ [ "start", start_func ], ["end", end_func] ]
for arr in commands
if arr[0] == str
command = arr[1]
break
end
end
command args
the last line 'command args' would then execute the command.
Is this possible? Is there a better solution for command recognition
without endless if/elsif/..?
Thanks,
Alex McHale, Daimun