根据Scala Language Specification,我们有
abstract class Any {
...
final def == (that: Any): Boolean =
if (null eq this) null eq that else this equals that
...
}
abstract final class Null extends AnyRef
我的问题是上述内容是否等同于以下重构:
abstract class Any {
...
final def == = equals
...
}
case object null extends AnyRef {
override def equals(that: Any): Boolean = that match {
case that: AnyRef => null eq that
case _ => false
}
}