Chapter 5. Using implicits to write expressive code
- Introduction to implicits
- Mechanics of the implicit resolution system
- Using implicits to enhance classes
- Using implicits to enforce scope rules
The implicit system in Scala allows the compiler to adjust code using a well-defined lookup mechanism. A programmer in Scala can leave out information that the compiler will attempt to infer at compile time. The Scala compiler can infer one of two situations:
- A method call or constructor with a missing parameter.
- Missing conversion from one type to another type. This also applies to method calls on an object that would require a conversion.
In both of these situations, the compiler follows a set of rules to resolve missing data ...
Get Scala in Depth now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.