How to check whether an empty array variable is null?

Ozan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 11 01:54:36 PDT 2015


On Saturday, 10 October 2015 at 15:46:51 UTC, Meta wrote:
> 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".
>>
....
> }

Do I miss the point?
Shouldn't have "new int[0]" , "[]" , ".length = 0" and "null" the 
same meaning like "array is empty"? I never understood why [] and 
null have different meanings in other languages.

And following the discussion...In my mind, aren't pointer 
operations dangerous?...yes,sometimes necessary...but always like 
an operation on a open heart.

Regards, Ozan


More information about the Digitalmars-d-learn mailing list