I'd like to be able to store a function in a hashtable. I can create a map like:
hash = {}
hash["one"] = def():
print "one got called"
But I'm not able to call it:
func = hash["one"]
func()
This produces the following error message: It is not possible to invoke an expression on type 'object'. Neither Invoke
or Call
works.
How can I do it ? From what I'm guessing, the stored function should be cast to something.