Is empty array null?

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 5 07:22:19 PST 2012


On Mon, 27 Feb 2012 16:12:44 -0500, Pedro Lacerda <pslacerda at gmail.com>  
wrote:

> Ouch, I just found http://d.puremagic.com/issues/show_bug.cgi?id=3889
>
> So how would I differ from an empty array and a null value?

You shouldn't.  A null-pointer array is a valid empty array.  It can be  
appended to, passed around, without consequence and behaves exactly as an  
empty array.

If you must:

if(arr.ptr == null) // check for a null array pointer.

-Steve


More information about the Digitalmars-d-learn mailing list