Given that myVals is a dynamic array of ints...

writeln("Array contents: ", myVals);
writeln("Sorted: ", sort(myVals));
writeln("Sorted, reversed: ", reverse(myVals));

Gives me...

Error: template std.stdio.writeln cannot deduce function from argument types !()(string, void)

But, if I bring the reverse out of the call to writeln() it works as expected:

writeln("Array contents: ", myVals);
writeln("Sorted: ", sort(myVals));
reverse(myVals);
writeln("Sorted, reversed: ", myVals);

Can someone give me a simple explanation as to why this is so? I guess it might be because reverse is 'in place' and the target is undefined at compile time but surely that would still be the case in the second instance. Somehow it doesn't seem logical to a noob like me.


Reply via email to