I am using an Array List to build a sequence of log items to later log. Works a treat, but the Add method emits the current index to the pipeline. I can address this by sending it to $null, like this
$strings.Add('junk') > $null
but I wonder if there is some mechanism to globally change the behavior of the Add method. Right now I have literally hundreds of > $null
repetitions, which is just ugly. Especially when I forget one.
I really would like to see some sort of global variable that suppresses all automatic pipelining. When writing a large script I want to intentionally send to the pipeline, as unexpected automatic send to pipeline is a VERY large fraction of my total bugs, and the hardest to find.
Add()
method. Why are you using anArrayList
collection in the first place? Do you need a particular feature that regular PowerShell arrays don't provide? – SweeperCollections.Generic.List<T>
as answer to this question... it's been there since .NET 2.0 iirc – Halm