char[] == null

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Nov 19 07:38:05 PST 2015


On 11/19/15 5:04 AM, Spacen Jasset wrote:
> On Thursday, 19 November 2015 at 08:30:54 UTC, Jonathan M Davis wrote:
>> On Wednesday, November 18, 2015 22:15:19 anonymous via
>> Digitalmars-d-learn wrote:
>>> [...]
>>
>> Exactly. T[] _is_ a dynamic array. Steven's otherwise wonderful
>> article on arrays in D ( http://dlang.org/d-array-article.html ) made
>> the mistake of calling the buffer that T[] points to on the GC heap
>> (assuming that even does point to the GC heap) the dynamic array. And
>> per the language spec, that's not true at all.
>>
>> [...]
>
> I mentioned this because it's bit of an error trap, that I fell into.
>
> char[] == null
> vs
> char[] is null
>
> Is there any good use for char[] == null ? If not, a warning might be
> helpful.

Of course, if you are comparing something to an empty array, null is an 
effective literal to create one.

-Steve


More information about the Digitalmars-d-learn mailing list