[Submission] D Slices

Daniel Gibson metalcaedes at gmail.com
Tue May 31 06:12:30 PDT 2011


Am 31.05.2011 15:13, schrieb eles:
> int[] b = a[0..2];   // This is a 'slicing' operation.  b now refers to
> the first two elements of a
> 
> is not the first *three* elements of a?

No, it contains a[0] and a[1].
The right boundary of a slice is exclusive. This makes sense, so you can
do stuff like a[1..$] (== a[1..a.length]) to get a slice that contains
all elements of a except for the first one (a[0]).

Cheers,
- Daniel


More information about the Digitalmars-d mailing list