O'Reilly logo

Scala in Depth by Joshua D. Suereth, Foreword by: Martin Odersky

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Using implicits to write expressive code

 

In this chapter
  • 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required