是否可以在 Scala 中的类型别名中使用上下文边界?
例如
type U = A : B
最佳答案
不,因为上下文绑定(bind)实际上是额外隐式参数的简写。
例如:
def sort[A : Ordering](xs: Seq[A])
是
的简写形式def sort[A](xs: Seq[A])(implicit ordering: Ordering[A])
这不能用类型定义来表示。
关于scala - 在类型别名中使用上下文绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9680630/