Summary

We have discussed three types of implicits in this chapter. These include implicit conversions, implicit classes, and implicit parameters.

We also discussed the syntactic sugar that's provided by the language in the form of view bounds and context bounds. We've seen how the former allows for defining implicit conversions in a somewhat concise way and that the latter does the same for type classes.

We compared object-oriented and type class based approaches in regards to polymorphic behavior. To depend on our knowledge of the topic, we worked through the recursive resolution of case classes and showed an example of type class variance.

In conclusion, we studied how the three levels of implicit scope resolution work. We've shown that all implicits in the lexical scope have the same precedence. The implicit scope is only looked at by the compiler if no suitable implicit can be found in the lexical scope. If there are multiple implicits in the scope, the static overloading rules are used to resolve possible conflicts.

This chapter concludes part of the book dedicated to Scala language constructs. In the following chapters, we'll move over to more complex concepts. But before doing this, in the next chapter, we'll take a brief digression into property-based testing to learn about some of the techniques we'll use to validate assumptions about the code we'll write in the second part of this book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.22.160