Curly braces on their own line or not?

Posted by TomWij on Programmers See other posts from Programmers or by TomWij
Published on 2010-09-10T22:15:38Z Indexed on 2011/01/17 7:59 UTC
Read the original article Hit count: 408

Filed under:
|
|

Should curly braces be on their own line or not? What do you think about it?

if (you.hasAnswer()) {
    you.postAnswer();
} else {
    you.doSomething();
}

or should it be

if (you.hasAnswer())
{
    you.postAnswer();
}
else
{
    you.doSomething();
}

or even

if (you.hasAnswer())
    you.postAnswer();
else
    you.doSomething();

Please be constructive! Explain why, share experiences, back it up with facts and references... ;-)

© Programmers or respective owner

Related posts about discussion

Related posts about holy-war