2010-12-23 78 views

回答

7

你是对的,这就是你需要做的。在Ordered其他方法将使用其默认的实现,这会按如下步骤:

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) 

不具有在Ordered一个默认的实现比较的唯一的事情,你会使用旧compareTo方法来定义。如果以上是您想要的其他比较,应该可以工作。

+1

太好了,谢谢! – soc 2010-12-23 14:55:39