【发布时间】:2016-12-23 03:58:44
【问题描述】:
我有以下方法:
def test[T](implicit ev: T <:< Int, t : T) = println(t)
我怎么称呼它?我试过了
test(10)
但是编译器打印出以下错误:
Error:(19, 9) not enough arguments for method test: (implicit ev: <:<[T,Int], implicit t: T)Unit.
Unspecified value parameter t.
test(10)
^
首先,我认为我们可以省略隐式参数而只指定显式参数。其次,为什么说参数t是隐式的?
implicit t: T
它实际上是如何工作的?
【问题讨论】: