arrays: if(null == [ ])

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Mon May 14 06:00:25 PDT 2012


I think any kind of null array should be different from an array of zero
length.

On Mon, May 14, 2012 at 3:55 PM, simendsjo <simendsjo at gmail.com> wrote:

> On Mon, 14 May 2012 13:51:40 +0200, deadalnix <deadalnix at gmail.com> wrote:
>
>  Le 14/05/2012 12:49, Gor Gyolchanyan a écrit :
>>
>>> So, null arrays and empty arrays are always the same, except for an
>>> empty string, which is a valid non-nill array of characters with length
>>> 0, right?
>>>
>>>
>> If it is the current behavior, it deserve a WAT !
>>
>
> It is according to my tests.. It's quite a gotcha.
> So check for .length or == "" or == [] if you need "null or empty" and use
> "is null" for null/[]
>



-- 
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120514/4ca69925/attachment.html>


More information about the Digitalmars-d mailing list