I want to create an array of arrays in powershell.
$x = @(
@(1,2,3),
@(4,5,6)
)
Works fine. However, sometimes I have only one array in the array list. In that situation, powershell ignores one of the lists:
$x = @(
@(1,2,3)
)
$x[0][0] # Should return 1
Unable to index into an object of type System.Int32.
At line:1 char:7
+ $a[0][ <<<< 0]
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : CannotIndex
How do I create an array of arrays, guaranteed it's remain as a two-dimension array even if the array has only one array item in it?