In the following snippet I have a minimum viable reproduction of a problem I'm having, I have a function, which returns an arraylist after adding a few items:
function dostuff(){
$Affixes = [System.Collections.ArrayList]@()
$Affixes.Add("i1")
$Affixes.Add("i2")
$Affixes.AddRange(@("i3","i4"))
return $Affixes.ToArray()
}
$Affixes = dostuff
$Formatted = $Affixes -join ','
Write-Host $Formatted
The output from this script is unexpected to me:
0,1,i1,i2,i3,i4
Why are there seemingly indexes at the beginning of my output? Why are they prepended like this?