Code examle:

import std.stdio;

class Foo
{
}

void main()
{
        Foo f;
        
        if(f)
        {
                writeln("f is true");
        }
        else
        {
                writeln("f is false");
        }
        
        f = new Foo();
        
        if(f)
        {
                writeln("f is true");
        }
        else
        {
                writeln("f is false");
        }
}

Programm output:

f is false
f is true


So, pointer implicitly converts to false if pointer is null and to true if pointer is not null. Is it bug or terrible feature? Note that we have `f is null` syntax for these cases.

Reply via email to