Inconsistent Array Initialization Behaviour
Creating an array of arrays as below works well:
$myArray = @(
$myArray #outputs 1, 2, 3
$myArray #outputs 4, 5, 6
$myBuggyArray = @(
$myBuggyArray #outputs 1
$myBuggyArray #outputs 4, 5, 6
I wouldn't expect the order of line break & comma to impact the behaviour of the command / can't find any documentation stating that it should.
Not a bug, but granted unexpected. Review: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-6
@( ) Array subexpression operator
Returns the result of one or more statements as an array. If there is only one item, the array has only one member.
) # Out 1
This is not a nested array because the inner subexpressions are evaluated and the resulting elements gathered into the outer array.
, Comma operator
As a binary operator, the comma creates an array. As a unary operator, the comma creates an array with one member. Place the comma before the member.
Here the comma is a binary operator which results in the second line being treated as a continuation of the first line and creating the expected nested array.
Here we have two individual statements. The first evaluates to three elements. In the second he comma is a unary operator which creates a single member array (with a nested array in it).
To my untrained eyes, it looks like a tokenization/parsing error... and a maddening one at that.
howdy John Bevan,
a leading comma does something special with arrays. i don't know what it should do in your sample code, but it otta force an array to be added as an array, not as more elements in the 1st array.
running our code sample, i get 1,4,5,6 for the  item in the array.
it certainly aint what i expected. [*sigh ...*]