Line continuation character in Scala
I want to split the following Scala code line like this:
ConditionParser.parseSingleCondition("field=*value1*").description must equalTo("field should contain value1")
But which is the line continuation character?
Answers
Wrap it in parentheses:
(ConditionParser.parseSingleCondition("field=*value1*").description must equalTo("field should contain value1"))
Scala does not have a "line continuation character" - it infers a semicolon always when:
- An expression can end
- The following (not whitespace) line begins not with a token that can start a statement
- There are unclosed ( or [ found before
Thus, to "delay" semicolon inference one can place a method call or the dot at the end of the line or place the dot at the beginning of the following line:
ConditionParser. parseSingleCondition("field=*value1*"). description must equalTo("field should contain value1") a + b + c List(1,2,3) .map(_+1)