What's behind this implicit cast in Scala?
casting, scala
Solution
On the JVM, scala's `String` is just an alias to `java.lang.String`. The fact that the Repl sometimes displays the type as `String` and sometimes as `java.lang.String` is just a minor (REPL specific) glitch that does not affect in any way the runtime behaviour.
For what it's worth, here is what I get in scala 2.10-RC1:
scala> "abc"+4
res0: String = abc4
scala> 4+"abc"
res1: String = 4abc
Problem
I'm not familiar with Scala and come across this problem below when using interactive mode: ``` scala>"abc"+4 res0: java.lang.String = abc4 scala>4+"abc" res1: String = 4abc ``` What I'm curious about is that how the type of the result can be different(`java.lang.String` vs `String`). And in Book Seven Languages in Seven Weeks the two types are both `java.lang.String`. BTW,the version of scala interpreter is 2.9.1.