I need to call a function and I need pass its parameters in a dynamic way:
params := ["param1", "param2", "param3"]
func("myFunc").Call(params)
I am intending for the above mean the “literal” equivalent of myFunc("param1", "param2", "param3")
but when I run the code, the function does not receive any parameters but it does with something like this:
params := ["param1", "param2", "param3"]
func("myFunc").Call(params[1], params[2], params[3])
Currently I am doing something like this, which is not ideal:
params := ["param1", "param2", "param3"]
if (params.MaxIndex() = 1)
func("myFunc").Call(params[1])
else if (params.MaxIndex() = 2)
func("myFunc").Call(params[1], params[2])
else if (params.MaxIndex() = 3)
func("myFunc").Call(params[1], params[2], params[3])
Any help would be greatly appreciated!