Hello! I read documentation about memory management and can't find description about delay allocation of instance. I have a method marked by @nogc. This method takes boolean variable. If this variable is true I want to construct object with one set of parameters else I want to construct object with another set of parameters. Take a look at code for clearance.

void method(bool flag) @nogc
{
        scope MyClass obj;
        if(flag) {
                obj = new MyClass(1);
        } else {
                obj = new MyClass(2);
        }
        // using obj
}

But this code CAN'T be compiled. How should I declare object for delay construction.
Thanks.

Reply via email to