PROPOSAL: open and close brace optional for single statement try, catch, finally, method declaration (original) (raw)

Ulf Zibis Ulf.Zibis at gmx.de
Mon Mar 30 08:01:49 PDT 2009


Am 30.03.2009 16:25, Neal Gafter schrieb:

Perhaps, but the Java grammar does not have a dangling-else ambiguity.

Neal, I don't understand. Please explain why Java does not have the dangling-else ambiguiaty.

if (..)
    if (..)
        ...;
else
    ...;

is in fact:

if (..) {
    if (..)
        ...;
    else
        ...;
}

and not:

if (..) {
    if (..)
        ...;
}
else
    ...;

Following "solution" should be a compile error:

if (..)
    if (..)
        ...;
    ;
else
    ...;

-Ulf



More information about the coin-dev mailing list