pedrofurla is right. With your expression, the compiler is trying to mix the string with if and fail. Using parentheses, you eliminate the ambiguity in your expressions.
class MyClass{ override def toString = "123:" + (if (true) "456" else "789") }
I found this simple online service where you can test scala expressions: http://www.simplyscala.com/
source share