Powershell param declaration alternatives

declaration, parameters, powershell

Solution

Except for convenience, there's no difference. Both ways are valid. Using param (in my opinion) is more readable especially in advanced functions where a parameter declaration may contain a few lines of code and you can use indentation and line breaks.

Problem

What's the difference between: ``` function foo ([int] i, [string] s) { ... } ``` And: ``` function foo { param ( [int] i, [string] s ) { ... } } ``` The help on MSDN does not explain this. Thanks!

Original source