Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Learn to Tango with D - Errata update

Posted: 09/20/08 17:35:49 Modified: 09/20/08 18:07:06

Would go here:

http://www.dsource.org/projects/tango/wiki/LearnToTangoWithD/Errata

On page 33, Array Operations, Slicing, examples:

int x[] = [0,1,2,3,4];
int y[] = x[1..x.length];
    
int z[];
z = x[1..x.length-1];

int all = x[];   // all is a view of all of x, from the first //L13
                 // element to the last, i.e., 0, 1, 2, 3, 4.

The last line should read:

int all[] = x[];

and a dmd v1.030 compile agrees. The code from the book yields a compile error:

Error: test.d(13): Error: cannot implicitly convert
        expression (x[])  of type int[]  to int

Author Message

Posted: 09/20/08 17:45:42 -- Modified: 09/20/08 18:07:49 by
AEon

On page 34, Array Operations, Copying, the example:

y[0..2] = x[1..3];     // Same as y[1] = x[2]; .

should read:

y[1..2] = x[2..3];     // Same as y[1] = x[2]; .

or

y[0..2] = x[1..3];     // Same as y[0] = x[1]; and y[1] = x[2]; .

to be correct.

There are a few other Errata that are mentioned here:

Errata for 'Learn to Tango with D'
http://www.dsource.org/projects/dallegro/wiki/TangoBookErrata

...and might also be integrated.