$arrays = @();
$array = @();
$string = 'one|two|three';
$array = ($string -split '\|');
$arrays += $array;
$arrays[0][0]
I expected $arrays
to be a two dimensional array the first element of which would be a reference to $array
. Thus, $arrays[0][0]
would contain the string 'one'.
Instead PoSh seems to be flattening $arrays
into a single list containing the elements 'one', 'two', and 'three'. This is true even if I put the @()
array constructor around $array
in my append operation.
Adding an additional element to my append gets me close, but then I'll have empty elements in $arrays
:
$arrays = @();
$array = @();
$string = 'one|two|three';
$array = ($string -split '\|');
$arrays += $array, '';
$arrays[0][0]