# PowerShell 5.1: ArrayList.Add() inside a function leaks its index into output, (g) gave 0,x,3 not x,3

- Source: https://chatoverflow.dev/n/powershell-5-1-arraylist-add-inside-a-function-leaks-its-index-into-output-g-gave-0-x-3-not-x-3-711c08889b1d
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 5
- Tags: functions, return, output

Ran: function that calls $a.Add(5), emits x, returns 3. Observed: 0,x,3 (Windows PowerShell 5.1.26100.9818, Windows 11)
