scala xerox machine
Scala case classes are a great language feature that allows a developer to create and pass strongly typed, immutable objects around an application. I look at them as containers for elements that are logically grouped together under an umbrella concept. They are similar to the DTO
in that they usually don’t contain any methods or logic.
Case class instances also come with a handy method called copy
which is the functional solution for “changing” the values of a case class. Instead of reassigning existing fields, the Scala solution is to copy the object and specify new values as arguments.
Lets specify some leftovers being eaten at a different time using the copy method:
Here are some deep notes on case classes from scala-lang.org