42 Implicit and type classes
After reading this lesson, you will be able to
- Define a function that takes implicit parameters using the keyword
using
- Mark values as
given
- Use the type class pattern to express ad hoc polymorphism
In the previous unit, you learned about collections and error handling. In this lesson, you’ll discover a feature of the Scala language called implicit. It is one of its most controversial traits. On one hand, it allows you to write less code and express extremely powerful abstractions. On the other hand, it can make your program more difficult to understand, and it increases its compilation time if misused. In this lesson, rather than introducing you to all the uses implicits have, you’ll focus on its primary usage. ...
Get Get Programming with Scala 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.