String to boolean inconsistency
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sat Dec 11 18:50:24 PST 2010
Actually I'm having a hard time understanding this:
void main()
{
string s = "";
assert(s); // pass, but why?
assert(s !is null); // pass
}
void main()
{
string s = "".idup;
assert(s); // fail
assert(s !is null); // pass
}
On 12/12/10, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> 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