June 2010
Intermediate to advanced
456 pages
14h 48m
English
The previous chapters indirectly acquainted us with arrays, associative arrays, and strings—an expression here, a literal there—so it’s time for a closer inspection. A lot of good code can be written using only these three types, so learning about them comes in handy now that we have expressions and statements under our belt.
D offers a simple but very versatile array abstraction. For a type T, T[] is the type of contiguous regions of memory containing elements of type T. D calls T[] “array of values of type T” or, colloquially, “array of Ts.”
To create a dynamic array, use a new expression (§ 2.3.6.1 on page 51) as follows:
int[] array =