A rewriting of the inject method in the Array class