I’m primarily a Python developer but I am unfortunately having to write a GUI-based program in VB .NET for a client. I’ve been able to figure out most of VB’s peculiarities myself, but I’ve had no luck finding a way to translate this simple idiom into VB:
def my_function(arg1, arg2, arg3):
# do stuff with args
pass
args = [1,2,3]
my_function(*args)
I’m dealing with some nasty functions with lots of variables, and the code would be a lot nicer and more readable if I could do something like that so I’m not stuck with
MyFunction(reader(0), reader(1), reader(2), reader(3)) 'ad infinum
Sort of! First off, if it makes it more convenient for you, though, you can do the opposite. They’re called parameter arrays:
So these are equivalent:
But if you really want a splat-ish thing, then that’s delegates:
If you can’t find an
ActionorFuncto suit your needs, then you need to define your own delegate type to match:and