Scala Typeclass

Typeclasses woooohh , sorry it is a bit late for scary Halloween words but here we are !

More seriously, we already saw all the components of what a Typeclass is but we haven't formalized the word.

We saw generic type before

And we learned about implicit val as well and how to use them.

I am just introducing implicit object while we are at it. But it works the exact same way.

So what are Typeclasses ? It is just a construct that involve a trait, implicit implementations and a function that leverage those implicit implementations

That's it !

As always, we talked about it in the past, using implicit can be dangerous and hard to maintain. It is easy to forget where the implementation is and it can be hard to find it back depending on the IDE you are using. Also debugging can be tricky. Use it when it seems right !

Reveal more information and clues
Load Exercise