Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Problem of return an array from function

$
0
0

Below is the example with strange behavior (missing the value of first index)

[array]$container

$container = @(0..2)

function TestPassArray () {

    [array]$fcontainer

    $fcontainer = @(0..2)

    $fcontainer[0] = '123'

    $fcontainer[1] = '456'

    $fcontainer[2] = '789'

    return $fcontainer

}

$container = TestPassArray

echo $container[0]


Viewing all articles
Browse latest Browse all 6937

Trending Articles