meissnersd
2007-11-18 17:32:00 UTC
Hey script quys.
I am trying to understand the return values for functions in Powershell
I defined a simple function in a script file.
function foo( [string] $ss ) {
$sb = new "System.Text.StringBuilder"
$sb.Append( $ss )
return $sb
}
I dot sourced it and then
MaxCapacity Length
--------
----------- ------
16
2147483647 1
16
2147483647 1
$x is an array of objects.
First I returned the string builder, not an array....
Second the string builder is in the array twice.
Huh?
I am trying to understand the return values for functions in Powershell
I defined a simple function in a script file.
function foo( [string] $ss ) {
$sb = new "System.Text.StringBuilder"
$sb.Append( $ss )
return $sb
}
I dot sourced it and then
. .\test.ps1
$x = foo "abc"
$x
Capacity$x = foo "abc"
$x
MaxCapacity Length
--------
----------- ------
16
2147483647 1
16
2147483647 1
$x is an array of objects.
First I returned the string builder, not an array....
Second the string builder is in the array twice.
Huh?