This problem is due to the fact that you are using multiline raw strings in the interpreter. You can see that the width of the extra spaces is exactly the size of the scala>
prompt or the size of the pipe + spaces added by the interpreter when you create a new line in order to keep things lined up.
scala> val rawString = """here is some text // new line
| and now im on the next line // scala adds spaces
| and this is the thrid line, and we're done""" // to line things up
// note that the comments would be included in a raw string...
// they are here just to explain what happens
rawString: java.lang.String =
here is some text
and now im on the next line
and this is the thrid line, and we're done
// you can see that the string produced by the interpreter
// is aligned with the previous spacing, but without the pipe
If you write your code in a Scala script and run it as scala filename.scala
you do not get the extra tabs.
Alternatively, you can use the following construct in the interpreter:
val rawString = """|here is some text
|and now im on the next line
|and this is the thrid line, and we're done""".stripMargin
println(rawString)
What stripMargin
does is strips anything before and including the |
character at the start of every line in the raw string.
EDIT: This is a known Scala bug -- thanks extempore :)
UPDATE: Fixed in trunk. Thanks extempore again :).
Hope it helps :)
-- Flaviu Cipcigan