Home > Back-end >  How does the implicit conversion for int2double come in scope
How does the implicit conversion for int2double come in scope

Time:12-06

The following conversion works because of int2double implicit conversion

scala> val d: Double = 2
d: Double = 2.0

prior to 2.10, this implicit conversion was part of Predef object and was thus always in scope. However since 2.10, it has been moved to Int companion object. How does the implicit conversion still work without any import?

CodePudding user response:

For implicits, besides the local scope (including imported ones), there is the implicit scope

Where does Scala look for implicits?

https://www.scala-lang.org/files/archive/spec/2.11/07-implicits.html

The actual arguments that are eligible to be passed to an implicit parameter of type

  • Related