array !is null fails

Jarrett Billingsley kb3ctd2 at
Tue Feb 13 07:13:31 PST 2007

"BCS" <ao at> wrote in message 
news:ce0a334373d48c91d12a1b9c0ec at
> Ah... I though that [i..i].length == 1?

Nope, since the second index is noninclusive, [i..i + 1] will be one element 
(just i), and [i..i] is 0.

> What good is the (array !is null) if it doesn't tell you when the pointer 
> is null?

Well if you want to see if the pointer is null then use "if(array.ptr is 
null)".  Though I'll agree with you that the discontinuity between 
zero-length null pointer arrays and more-than-zero-length null pointer 
arrays is a bit odd. 

More information about the Digitalmars-d-learn mailing list