"".dup is null

Qian Xu quian.xu at stud.tu-ilmenau.de
Mon May 4 07:16:59 PDT 2009


Steven Schveighoffer wrote:

> On Mon, 04 May 2009 09:46:57 -0400, Qian Xu <quian.xu at stud.tu-ilmenau.de>
> wrote:
> 
>> Hi All,
>>
>> The following code will throw an exception:
>>   char[] s;
>>   assert( s.dup  is null); // OK
>>   assert("".dup !is null); // FAILED
>>
>> "".dup is expectly also an empty string.
>> Is this a compiler bug?
>>
> 
> I think you might have a bug?
> 
> "".dup is the same as s.dup, not sure why you would expect it to be
> not-null.
> 
> -Steve

They are not the same. s is null. "" is an empty string. empty string and
null are definitely two thing.


More information about the Digitalmars-d-learn mailing list