为什么Scala的RichInt扩展了Comparable[Int]而不是Comparable[RichInt]
我是斯卡拉的新手。在浏览Scala库代码时,我注意到类RichInt扩展了ScalaNumberProxy[Int],ScalaNumberProxy扩展了OrderedProxy,OrderedProxy扩展了Ordered,Ordered扩展了java.lang.Comparable。因此,我的理解是RichInt (间接地)扩展了java.lang.Comparable[Int]。
我的问题是为什么它不扩展java.lang.Comparable[RichInt]
我提出这个问题的原因是用Java编写这样的代码:
class A implements Comparable<A> {
@Override
public int compareTo(A other) {
//implement the method.
}
....
}https://stackoverflow.com/questions/49102341
复制相似问题