Curly Braces

Opening curly braces ({) must be on the same line as the declarationthey represent:

  1. def foo = {
  2. ...
  3. }

Technically, Scala’s parser does support GNU-style notation withopening braces on the line following the declaration. However, theparser is not terribly predictable when dealing with this style due tothe way in which semi-colon inference is implemented. Many headacheswill be saved by simply following the curly brace conventiondemonstrated above.

Parentheses

In the rare cases when parenthetical blocks wrap across lines, theopening and closing parentheses should be unspaced and generally kept on the samelines as their content (Lisp-style):

  1. (this + is a very ++ long *
  2. expression)

Parentheses also serve to disable semicolon inference, and so allow the developerto start lines with operators, which some prefer:

  1. ( someCondition
  2. || someOtherCondition
  3. || thirdCondition
  4. )

A trailing parenthesis on the following line is acceptable in this case, foraesthetic reasons.