Scala Typeclass

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

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

We saw generic type before

And we learned aboutimplicit valas well and how to use them.

I am just introducingimplicit objectwhile we are at it. But it works the exact same way.

So what areTypeclasses? It is just a construct that involve atrait,implicitimplementations and a function that leverage thoseimplicitimplementations

That's it !

As always, we talked about it in the past, usingimplicitcan 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