string <-> null/bool implicit conversion

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 20 12:08:55 PDT 2015


On 8/20/15 2:43 PM, Timon Gehr wrote:
> On 08/20/2015 07:50 PM, Steven Schveighoffer wrote:
>>
>> Very true. Not much we can do about it. For now, the best thing to do is
>> always compare arrays to null instead of simply if(arr):
>>
>> if(arr != null)
>>
>> Alternatively, but a little more ugly, is to check the length:
>>
>> if(arr.length)
>
> Isn't the best way to compare to []?
>
> if(arr!=[])
>
> I think comparing to null is needlessly confusing.

Same thing. [] is null.

-Steve


More information about the Digitalmars-d mailing list