Skip to content

Instantly share code, notes, and snippets.

@joyhuang9473
Last active October 18, 2015 07:02
Show Gist options
  • Save joyhuang9473/99233653773f4f5b846f to your computer and use it in GitHub Desktop.
Save joyhuang9473/99233653773f4f5b846f to your computer and use it in GitHub Desktop.
Prefer no spaces inside parentheses. The if and else keywords belong on separate lines.
if (condition) { // no spaces inside parentheses
... // 4 space indent.
} else if (...) { // The else goes on the same line as the closing brace.
...
} else {
...
}
// Sort conditional statements may be written on one line if this enhances readability.
if (x == kFoo) return new Foo();
// curly braces are required for single-line statements
if (condition) {
DoSomething(); // 4 space indent.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment