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?
Strings in Scala are single lines that are wrapped into double quotes. We can create multiline strings in Scala by surrounding the text with three double quotes or using pipes through a stripMargin(). While creating the multiline string, you can control to maintain the original indentation and formatting.
To write the second line into a new line, write a new line character to the file after the first line. New line character is indicated by "\n". so, you will write "Hello Scala", then "\n" followed by "Bye Scala" to the file.
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:
(
or [
found beforeThus, 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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With