How can I write a string that spans multiple lines?
I tried to use the line continuation character \
at the end like many other languages, but it does not seem to work. The following:
val s = "line1\
line2";
generates an error:
/tmp/...:1: error: unexpected character l in \ ... \
/tmp/...:1: error: no matching quote found on this line
Not using any line continuation as follows generates a similar error:
val s = "line1
line2";
What's the correct way to write a multiline string?
CodePudding user response:
You have to put the backslash at the beginning of the next lines as well :
print "this is\
\ a string on\
\ 3 lines\n";