Numeric access to char[]

Derek Parnell derek at
Wed Aug 23 20:06:37 PDT 2006

On Thu, 24 Aug 2006 04:33:53 +0200, Peter Thomassen wrote:

> Okay, nearly understood. But doesn't [0..1] produce two items, namely [0]
> and [1]?

The semantics of a slice specification is that the slice starts with the
element indexed by the first index and extends to all the elements up to,
but not including, the second index. Thus [0..1] means a slice containing
element[0] only, and [4..7] means element[4], element[5], and element[6] is
included in the slice, but not element[7]. To get all the elements except
the last element we can use [0..$-1] 

(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
24/08/2006 1:05:56 PM

More information about the Digitalmars-d-learn mailing list