How to check whether an empty array variable is null?

rumbu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Oct 10 08:29:30 PDT 2015


On Saturday, 10 October 2015 at 15:20:04 UTC, tcak wrote:
> [code]
> 	int[] list;
>
> 	list = new int[0];
>
> 	std.stdio.writeln("Is Null ? ", (list is null));
> [/code]
>
> Result is "Is Null? true".
>
> Is this the correct behaviour? I would expect compiler to point 
> to an address in the heap, but set the length as 0. So, it 
> wouldn't return null, but the length would be 0 only.


Long discussion: 
http://forum.dlang.org/thread/rrrtkfosfnfuybblexow@forum.dlang.org



More information about the Digitalmars-d-learn mailing list