Good question. I'm not aware of any definitive article.
An easy way to see the difference:
PS>(1,2)|get-member
vs
PS>,(1,2)|get-member
In the first case, each element is passed to get-member. In the second
case, the elements remain grouped together and are passed as a whole to
get-member.
So at first, PowerShell sees the numbers 1 and 2 being passed, while in the
second, PowerShell sees a collection of 1 *and* 2 being passed together.
That being said, I'm not sure what's going on in your last example below.
Marco
"Kevin Buchan" <kevin.buchan@newsgroup[PlsDon'tSpam]sanders.com> wrote in
message news:n1bva5173gsjipm0gbsdimbiahafkv1q78@newsgroup
> I'm having trouble finding a definitive article on what exactly the
> leading comma does.
>
> PS C:\> $a
> PS C:\> $a = 1,2,3
> PS C:\> $b = 4,5,6
> PS C:\> ($a + $b).length
> 6
>
> It *seems* to treat what follows it as an element in an array, even if
> it's an array. So instead of creating a new array with all of the
> elements in $a and $b, it creates an array with all of the elements in
> $a and another array element with the entire $b array as that single
> element.
>
> PS C:\> ($a + ,$b).length
> 4
> PS C:\>
> PS C:\> $c = $a + ,$b
> PS C:\> $c[3].GetType().FullName
> System.Object[]
> PS C:\> $c[3]
> 4
> 5
> 6
> PS C:\> $c[3][0]
> 4
>
> When I try it before a string, I get an array with a single element,
> the string.
> PS C:\> $d = ,"Test","AnotherTest"
> PS C:\> $d.GetType().FullName
> System.Object[]
> PS C:\> $d.length
> 2
> PS C:\> $d[0]
> Test
>
>
> OK, all of that seems reasonable to me. But, now here's where my mind
> gets blown...
>
> Why, in this example below, is the first element of $e a
> multi-dimensional array instead of just being a simple array of
> integers?
> PS C:\> $e = ,(1,2,3),4,5,6
> PS C:\> $e.length
> 4
> PS C:\> $e[0].GetType().FullName
> System.Object[]
> PS C:\> $e[0][1] # I expected this to return '2'.
> PS C:\> $e[0][0]
> 1
> 2
> 3
> PS C:\> $e[0][0][1] # What the heck?
> 2
>
>
> --
> Kevin Buchan
> kevin.buchan@newsgroup[nospam]sanders.com


