statement is not reachable

Jarrett Billingsley jarrett.billingsley at gmail.com
Thu Mar 5 15:13:57 PST 2009


On Thu, Mar 5, 2009 at 10:45 AM, Qian Xu <quian.xu at stud.tu-ilmenau.de> wrote:
> Hi Jarrett,
>
> but I need an exception here. This is an unexpected case. I want no instance
> to be create in this case.

By the time the constructor runs, an instance has already been
created.  But if you throw an exception in the ctor, it's impossible
for a reference to that instance to be stored anywhere, unless you
store it within the ctor itself, i.e.

this()
{
    someGlobal = this;
    throw new Exception("foo!");
}


More information about the Digitalmars-d-learn mailing list