The $ args variable should, by definition, contain all the arguments passed to the script function. However, if I build a pipeline inside my function, the $ args variable evaluates to null. Does anyone know why?
See this example:
function test { 1..3 | % { echo "args inside pipeline: $args" } ; echo "args outside pipeline: $args" }
This is the result when the hello parameter is passed:
PS> test hello
args inside pipeline:
args inside pipeline:
args inside pipeline:
args outside pipeline: hello
Is there a specific reason for this? I know how to get around this, but I wonder if anonye can explain the reason for this.
driAn source
share