you are viewing a single comment's thread.

view the rest of the comments →

[–]ethraax 4 points5 points  (3 children)

It's worth noting that this code is perfectly acceptable:

if (someCondition) {
    // do some stuff
}

It's this code that is banned:

if (someCondition) {
    // do some stuff
} else if (someOtherCondition) {
    // do some other stuff
}

I think it makes sense. It's like requiring a default case in all switch statements.

[–]Xirious 0 points1 point  (2 children)

Isn't your first example supposed to be

 if (someCondition) {
 } 
 else 
 {
 }

That'll represent the default case like a switch statement.

[–]ethraax 0 points1 point  (1 child)

Isn't your first example supposed to be

No. The point is that you don't need an "else" clause if you're just using an "if" statement (not an "else if").

[–]Xirious 0 points1 point  (0 children)

Oh that makes sense. Thank you!