I want to create an empty array of arrays in Powershell to hold "tuples" of values (arrays are immutable).
Therefore I try something like:
The type of $arr is Object[]. I've read that += @(1,2) appends the given element (i.e. @(1,2)) to $arr (actually creates a new array). However, in this case it seems that the arrays are concatenated, why?
$arr = @()
$arr += @(1,2)
$arr.Length // 2 (not 1)
If I do as follows, it seems that $arr contains the two arrays @(1,2),@(3,4), which is what I want:
$arr = @()
$arr += @(1,2),@(3,4)
$arr.Length // 2
How do I initialize an empty array of arrays, such that I can add one subarray at a time, like $arr += @(1,2)?