implicits

Where does Scala look for implicits?

自古美人都是妖i 提交于 2019-11-25 21:53:35
问题 An implicit question to newcomers to Scala seems to be: where does the compiler look for implicits? I mean implicit because the question never seems to get fully formed, as if there weren\'t words for it. :-) For example, where do the values for integral below come from? scala> import scala.math._ import scala.math._ scala> def foo[T](t: T)(implicit integral: Integral[T]) {println(integral)} foo: [T](t: T)(implicit integral: scala.math.Integral[T])Unit scala> foo(0) scala.math.Numeric