Can I reproduce Scala's behavior for == ?
- by JPP
In Programming in Scala, I can read that the == operator behaves as if it was defined like this:
final def == (that: Any): Boolean = if (null eq this) {null eq that} else {this equals that}
But there must actually be compiler magic to avoid null pointer exceptions, right? Is there any way for me to replicate this behavior with pure Scala; i.e.,…