我在scala 2中有这个代码
val number = 20
def double(implicit y:Int)={
y*2
}
def count(implicit x:Int)={
double
}
object HelloWorld {
def main(args: Array[String]): Unit = {
println(count(number)) // res: 40
}
}
这里 x
对函数的参数进行了count
注释,implicit
因此它可以double
隐式传递给函数。Scala 3
在使用给定使用/召唤时如何做到这一点?