powershell constructor overloading quetion


I have a scripts which contains a class. The script takes many optional parameters. How can I pass the parameter to the class only if it exists? Is there similar way of passing arguments to classes like in python (args, *kwargs)?

Currently I have:

If($arg1) { [className]::New($foo, $arg1) } else { [className]::New($foo) }

this is relatively ok but what if I have more than one parameters to pass?

Is there a nicer way to do it?

thanks for help!

submitted by /u/pyr32
[link] [comments]

Leave a Reply