In PowerShell 4.0, Win 8.1, if I run this script:
$x = @(
("one","two","three"),
("four", "five", "six"),
("seven", "eight", "nine")
)
write-host $x.Count
$x | % {write-host "$_"}
I get
3
one two three
four five six
seven eight nine
If I run the exact same script, but with the commas removed between each of the three sub-arrays:
$x = @(
("one","two","three")
("four", "five", "six")
("seven", "eight", "nine")
)
write-host $x.Count
$x | % {write-host "$_"}
I get
9
one
two
three
four
five
six
seven
eight
nine
Interestingly, in the version with the commas removed, the newlines have to be there. If I remove them, the script won't run and gives "Unexpected token '(' in expression or statement" as the reason.
Why does this happen? My expectation is that it shouldn't run at all without the commas, regardless of the presence of newlines. This bit me when I added a new sub-array value to the bottom of a long array of similar values but forgot the comma, and the handling got all screwed up for the last value.