I want to create a 2-dimensional array in PowerShell Core 7.3 and assign just the first row:
$A = @(@( "Pink", "Yellow", "Orange", "Green", "Blue"))
Then I try to retrieve the 3rd element ("Orange"):
$A[0][2]
Output: n
It actually put all values in separate rows:
$A[0] is "Pink"
$A[1] is "Yellow"
etc.
The 2nd index will address the nth character in that row:
$A[0][0] is P
$A[0][1] is i
$A[0][2] is n
$A[0][3] is k
However, if I initialize the array with 2 rows, everything works as expected:
$A = @( @("Pink","Yellow","Orange","Green","Blue"), @("Hearts","Stars","Moons","Clovers","Diamonds"))
$A[0][2] is "Orange"
$A[1][3] is "Clovers"
How can I have just row 0 populated and still address each element with 2 indices like $A[0][…]
?
How would I initialize a new array with just one row of constant columns?