meant this: which of course also fails, but I hope you get the jist void setLength (T)( ref T array, int depth , int index[]) { if(depth > 0) { depth--; setLength (&array[index[0]], depth, index[1..$]); } else { if(array.length < index[0]) array.length = array.length * 2; } }