-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Closed
Labels
Description
For control statements, why do you prefer else
s to be on the same line as the if ending brace? 16.2
Under 8.3 - wrapping parens, you state that wrapping parens shows clearly where the function starts and ends.
I think that having the else
block start on the same line is less clear than if it starts on a separate line. This is especially the case if the code blocks are small. You might read the if
and skip over else
entirely.
Currently preferred - same line
if (test) {
thing1();
} else {
thing2();
}
vs
Separate lines
if (test) {
thing1();
}
else {
thing2();
}