gpt4 book ai didi

scala - 为什么我得到 "Could not find implicit value for parameter ord: scala.math.Ordering[T]"

转载 作者:行者123 更新时间:2023-12-02 07:49:00 25 4
gpt4 key购买 nike

我有一个简单的示例特征,它具有从 Ordered 派生的某种泛型类型的值。我找不到任何方法来实际使用该值,因为我得到“无法找到参数 ord 的隐式值:scala.math.Ordering [T]”。这是代码:

trait Example[T <: Ordered[_]] {
val key: T

def before(that: Example[T]): Boolean = (key < that.key)
}

为什么这不能编译?

最佳答案

在我看来应该是这样

trait Example[T <: Ordered[T]] {

关于scala - 为什么我得到 "Could not find implicit value for parameter ord: scala.math.Ordering[T]",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4809401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com