Skip to main content
Software Engineering

Return to Question

Question Protected by gnat
Post Closed as "not constructive" by Jeff Atwood
Notice removed by Jeff Atwood
Post Unlocked by Jeff Atwood
Question Unprotected by Community Bot
Notice added by user8
Post Locked by Community Bot
deleted 222 characters in body; edited tags; edited title
Source Link
user8
user8

Curly Should curly braces appear on their own line or not?

##Moderator Message

This question already has 40 answers. Therefore, there is a very good chance that your answer has already been provided. Please take a moment to review all the answers before posting.

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... ;-)

Curly braces on their own line or not?

##Moderator Message

This question already has 40 answers. Therefore, there is a very good chance that your answer has already been provided. Please take a moment to review all the answers before posting.

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... ;-)

Should curly braces appear on their own line?

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.

moderator message
Source Link
ChrisF
  • 39k
  • 11
  • 129
  • 169

##Moderator Message

This question already has 40 answers. Therefore, there is a very good chance that your answer has already been provided. Please take a moment to review all the answers before posting.

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... ;-)

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... ;-)

##Moderator Message

This question already has 40 answers. Therefore, there is a very good chance that your answer has already been provided. Please take a moment to review all the answers before posting.

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... ;-)

Question Protected by ChrisF
Bounty Ended with Jay Bazuzi's answer chosen by Tamara Wijsman
Post Made Community Wiki
Bounty Started worth 50 reputation by Tamara Wijsman
added 27 characters in body; edited tags; added 76 characters in body
Source Link
Tamara Wijsman
  • 8.2k
  • 14
  • 60
  • 95

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... ;-)

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();

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... ;-)

Rollback to Revision 3
Link
Tamara Wijsman
  • 8.2k
  • 14
  • 60
  • 95
Loading
edited tags
Link
user8
user8
Loading
added 104 characters in body
Source Link
Tamara Wijsman
  • 8.2k
  • 14
  • 60
  • 95
Loading
Gone with the "== true"! :-)
Source Link
Tamara Wijsman
  • 8.2k
  • 14
  • 60
  • 95
Loading
Source Link
Tamara Wijsman
  • 8.2k
  • 14
  • 60
  • 95
Loading

AltStyle によって変換されたページ (->オリジナル) /