Example within documentations of D seriously need some improvement.

Walter Bright newshound2 at digitalmars.com
Fri May 27 12:27:29 PDT 2011


On 5/27/2011 12:02 PM, Jesse Phillips wrote:
> Matthew Ong Wrote:
>
>> Perhaps format like coffee using more interesting side by side comparison
>> and with more writefln/writeln rather than assert. Assert does not show
>> anything visually.
>
> I understand this position and that new programers of D find it odd that
> examples don't have any output. However I have taking a liking to using
> assert as it documents what is expected and there is no need for a comment.
> On top of that it gets people familiar with assert and potentially using it
> in their own code and the icing is that unittests are built in the same
> manner (you should expect no output when everything is OK).


I tend to prefer the unambiguous:

     assert(1+2==3);

as opposed to the wordy and possibly misinterpreted:

     writeln(1+2); // should print 3


More information about the Digitalmars-d mailing list