-1

I'm a little confused which brace style is better?
This one?

if ( a > b)  
{  
    c = d;  
}  

or this one?

if ( a > b) {  
    c = d;  
}  

I'm using the first one because I think it's easy to read, but I found it seems that many experts (or experience programmers) like to use the second style, the second one looks like more professional (isn't is?). I know both styles are OK, but in your opinion, which one is better for a programmer? Your reasons? Thank you a lot!

Lemur
  • 2,659
  • 4
  • 26
  • 41
lkkeepmoving
  • 2,323
  • 5
  • 25
  • 31

2 Answers2

3

Do whatever is right for you, unless you program in a team. In that case, follow whatever coding style you all agree on.

Femaref
  • 60,705
  • 7
  • 138
  • 176
1

I personally use the second one, bu most IDEs' auto-formatters will use the first one. But it's just so minor difference that... I doubt that somebody would actually care.

Lemur
  • 2,659
  • 4
  • 26
  • 41