Scala case object

This one should be pretty quick.

Introducingcase object.

There is not much to it at first sight. It is the equivalent of whatcase classis forclassbut forobject.

Acase objecthas everything aobjecthave. Feel free to go back to the corresponding episode. But add also some convenient method. For instance the `toStringis a lot nicer, allowing you to get the name of thecase objectitself which allow for great logging.

It was not easy to introduce onlycase objectbecause their main use case is in the implementation of the Scala v2.x Enumerations which we are going to see next time. I wanted a dedicated episode to Enumeration but couldn't go for it untilcase objectwere introduced. Now that it is done, see you next time.

Reveal more information and clues
Load Exercise