-
-
Save rossabaker/443103 to your computer and use it in GitHub Desktop.
scala> null == 42 | |
res0: Boolean = false | |
scala> (null:java.lang.Integer) == 42 | |
java.lang.NullPointerException | |
at scala.runtime.BoxesRunTime.equalsNumNum(Unknown Source) | |
at scala.runtime.BoxesRunTime.equalsNumObject(Unknown Source) | |
at .<init>(<console>:6) | |
at .<clinit>(<console>) | |
at RequestResult$.<init>(<console>:9) | |
at RequestResult$.<clinit>(<console>) | |
at RequestResult$scala_repl_result(<console>) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:616) | |
at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun$apply$18.apply(Interpreter.scala:981) | |
at scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun... |
Thinks are becoming a bit sad. :(
It does some magic to allow different numeric types to be equal if they have the same value (for example., 5 == 5.0d). A lot of complexity comes with that magic, I think.
Arrays redesign with java interoperability and all that Manifest stuff is another point. Language gaining bit verbose with code not related to what you really want to do. Scala is loosing points and the chance to be the next big language. :(
I posted the equality problem to the Scala mailing list, and within a couple hours, a fix was committed. Hooray for Paul Phillips and the rest of the Scala dev team.
http://scala-programming-language.1934581.n4.nabble.com/and-equals-td2261488.html#a2262102
http://lampsvn.epfl.ch/trac/scala/changeset/22379/
The second expression also returns false in Scala 2.7.7.