为什么Ordered [A]使用比较方法而不是重用compareTo?

soc*_*soc 2 java comparison interop programming-languages scala

trait Ordered[A] extends java.lang.Comparable[A] {
  def compare(that: A): Int
  def <  (that: A): Boolean = (this compare that) <  0
  def >  (that: A): Boolean = (this compare that) >  0
  def <= (that: A): Boolean = (this compare that) <= 0
  def >= (that: A): Boolean = (this compare that) >= 0
  def compareTo(that: A): Int = compare(that)
}
Run Code Online (Sandbox Code Playgroud)

是不是有点用处有两个comparecompareTo?我在这里失踪的巨大好处是什么?

如果他们刚刚用compareTo我可能只是取代了ComparableOrdered在我的代码和完成.

Mar*_*sky 10

我认为这是一次历史性的事故.Ordered最初没有继承自Comparable.一旦它成功,compare名称已经建立.