Your usual application Scala code might contain some constructs that import other classes and objects, or it might also inherit other classes. You write methods that expect types as parameters and also declare parameters. So when the Scala compiler looks for an implicit value, where should it start looking for such a value? The compiler starts to look for an implicit value according to the following criteria:
- Defined in current scope
- Explicitly imported
- Imported using wildcards
- Companion object of a type
- Implicit scope of an argument's type
- Implicit scope of type arguments
- Outer objects for nested types
We know that if we define an implicit value in the current scope (block of code), it gets the highest precedence. Afterwards, you can also import it using an import statement, as shown in the following code:
import scala.concurrent.Future import scala...