Why the first operator does not quit, and the second does
In accordance with the specification of the language (6.3), nullthere are special methods that will not cause an appearance NullReferenceExceptionwhen called. They are defined as:
6.3 Null
null scala.Null , , . "" . scala.AnyRef :
eq(x) ==(x) true, x "" .ne(x) !=(x) true, x "null".isInstanceOf[T] false.asInstanceOf[T] T.## 0.
"" NullPointerException.
equals AnyRef null . eq, ( , ):
scala> null.==("goutam")
res0: Boolean = false
scala> null.eq("goutam")
res1: Boolean = false
== null, . == .equals Scala?