String to boolean inconsistency

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Dec 11 18:47:02 PST 2010


The first one should fail since the string has length 0. If you use an
.idup you would get the correct results:

void main()
{
string s = "".idup;
assert(s);  // fails
assert(s != null);  // ok
}

So I guess it's a bug.

On 12/12/10, Tomek Sowiński <just at ask.me> wrote:
> string s = "";
> assert(s);  // ok
> assert(s != null);  // fails
>
> I guess that's a bug. But which one is right?
>
> --
> Tomek
>


More information about the Digitalmars-d mailing list