foreach is a very bad choice for solving this. I blindly took it over from the original code. Need to get some sleep :). This now definitely works, and is also the shortest: void removeAt(T)(ref T[] arr, size_t index){ for(auto i = index; i; i--) arr[i] = arr[i - 1]; arr = arr[1 .. $]; } Timon