0
If Else statements when and where to use these respective braces.
What is the difference between: 1) if ( condition) { Statement } 2) if (condition) Statement
2 Answers
+ 3
When there is only one statement, braces can be omitted. (Option 2) but not necessary.
When there are more than one statements, you have to use proper braces. (option 1 must follow here).
ex:
1)
if(a>b)
{
max=a; //more than 1 statements
min=b;
..
}
2)
if(a>b)
max=a; //single statement.
0
Clean code says you shouldn't use 2nd statement as it's making code less readable ^^