Curly Braces
Opening curly braces ({
) must be on the same line as the declarationthey represent:
def foo = {
...
}
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):
(this + is a very ++ long *
expression)
Parentheses also serve to disable semicolon inference, and so allow the developerto start lines with operators, which some prefer:
( someCondition
|| someOtherCondition
|| thirdCondition
)
A trailing parenthesis on the following line is acceptable in this case, foraesthetic reasons.