On 4/13/2011 6:04 PM, Adam D. Ruppe wrote:
I don't know - I like the approach Andrei took in the docs, writing
a series of true assertations.

assert(sort([4, 2]) == [2, 4]);

does look pretty neat. I guess the alternative is:

writeln(sort[4, 2]); // prints "[2, 4]"

but it's not as compact with some examples and it doesn't quite
show the same thing - writeln's implementation could change things
there and those details are really beside the point of the example.

On the other hand, having output there might be more interesting
to look at than "yay the asserts all passed!".

I could go either way.

One advantage of the assert() approach is you won't have to over and over again add in the import std.stdio;

Not having any imports makes for a faster compile, too.

Reply via email to