Skip to content

Why cuddled elses? (brace style) #1709

Description

@merlinstardust

For control statements, why do you prefer elses 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();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions