On Tue, Dec 20, 2011 at 21:20, Andrej Mitrovic <[email protected]> wrote: > On 12/20/11, Dejan Lekic <[email protected]> wrote: >> I would go even further, and give a *function* as an argument - >> function that will be used to initialise values. > > Well I don't know about functions yet, but I did need to use another > array as an initializer. So the new implementation takes care of that > via lockstep:
from : http://www.ideone.com/gKFTK : unittest { auto arr2 = initializedArray!(int[][])([[1, 2], [3, 4]], 2, 2); assert(arr2 == [[1, 2], [3, 4]]); } 1) What's the difference with using auto arr2 == [[1,2],[3,4]].dup; ? (I honestly asks, I don't know much about D's assignements) 2) You can get the lengths of [[1,2],[3,4]], so the 2,2 args is redundant. What happens if you type: auto arr2 = initializedArray!(int[][])([[1, 2], [3, 4]], 4, 10); 3) I still think you should relax the constraint on the init value's type. You do not need it to be *exactly* BaseElementType!T. Thats stops you from writing auto arr2 = initializedArray!(float[][])(3, 2,3); 4-ish) No need to attribute the rank/BaseElementType code to me :-)
