I noticed that when running ForEach on an array object and capturing the output to a new variable, the new variable is not of type System.array:
PS D:\Playground> $Arr = 1, 2, 3
PS D:\Playground> $Arr2 = $Arr.ForEach({$_})
PS D:\Playground> $Arr2.Gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Collection`1 System.Object
Rather, it is of type Collection'1.
What is this type? Is it equivalent to an array?
BTW, this is not the same as with ForEach-Object:
PS D:\Playground> $Arr3 = $($Arr | ForEach-Object { $_ })
PS D:\Playground> $Arr3.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
ForEachmethod that returns aCollection<PSObject>(which is a very weird type to use, since it's intended as a base class -- but since it's not abstract, it is indeed possible to use it directly). No, this is not equivalent to an array, but because PowerShell mostly only cares if things are enumerable (not what the exact type is) and sinceCollectionis indexable just like an array, that doesn't usually matter much.$i = { 'asd' }.Invoke()=>$i.GetType()=> Collection`1 =>$i[0].GetType()=> string