"" gives an empty string, while "".idup gives null

bearophile bearophileHUGS at lycos.com
Wed Aug 3 06:49:07 PDT 2011


simendsjo:

> void main() {
>      assert(is(typeof("") == typeof("".idup))); // both is immutable(char)[]
> 
>      assert(""      !is null);
>      assert("".idup !is null); // fails - s is null. Why?
> }

I think someone has even suggested to statically forbid "is null" on strings :-)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list